Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > re: help on xslt

Reply
Thread Tools

re: help on xslt

 
 
timothy ma and constance lee
Guest
Posts: n/a
 
      10-21-2004
Sir

Sorry to bother you once again
The message structure change with <Resp>......</resp>
And I make the modification as below but i cannot display the drop list box
with number
It look like the length cannot be got

I simple add message/docList/docSet in for each case
and try by error using docList/totPage or simply totPage but i cannot
generate the drop box with index
any idea?


<?xml version="1.0"?>
> <xsl:stylesheet
> xmlnssl="http://www.w3.org/1999/XSL/Transform"
> version="1.0">
>
> <xslutput method="html" indent="yes"/>
>
> <xsl:key name="by-docSet" match="docSet" use="."/>
>
> <xsl:template match="/Resp">
> <html>
> <head>
> <title/>
> </head>
> <body>
> <table>
> <xsl:for-each select="/message/docList/docSet[generate-id(.) =
> generate-id(key('by-docSet', .)[1])]">
> <tr>
> <td>
> DocSet
> </td>
> <td>
> <xsl:value-of select="."/>
> </td>
> </tr>
> <xsl:for-each select="key('by-docSet', .)">
> <tr>
> <td>
> Document type
> </td>
> <td>
> <xsl:value-of
> select="following-sibling::docTp[1]"/>
> <select name="{following-sibling::docTp[1]}"
> onchange="url">
> <!-- calling a template to generate <option> tags > -->
> <xsl:call-template name="generateDropdown">
> <xsl:with-param name="length"
> select="following-sibling::totPage[1]" />
> </xsl:call-template>
> </select>
> </td>
> </tr>
> </xsl:for-each>
> </xsl:for-each>
> </table>
> </body>
> </html>
> </xsl:template>
>
> <!-- a recursive template to generate <option> tags > -->
> <xsl:template name="generateDropdown">
> <xslaram name="length" />
>
> <xsl:if test="$length &gt; 0">
> <option value="{$length}"><xsl:value-of
> select="$length" /></option>
> <xsl:call-template name="generateDropdown">
> <xsl:with-param name="length" select="$length -
> 1"/>
> </xsl:call-template>
> </xsl:if>
> </xsl:template>
>
> </xsl:stylesheet>



<Resp>
<message>
<docList>
<docSet>1</docSet>
<docTp>A1</docTp>
<totPage>5</totPage>
<docID>A111</docID>
</docList>
<docList>
<docSet>1</docSet>
<docTp>B1</docTp>
<docID>B111</docID>
<totPage>4</totPage>
</docList>
<docList>
<docSet>2</docSet>
<docTp>A2</docTp>
<totPage>6</totPage>
<docID>A2111</docID>
</docList>
<docList>
<docSet>1</docSet>
<docTp>C1</docTp>
<totPage>7</totPage><
<docID>C111</docID>
</doclist>
<docList>
<docSet>2</docSet>
<docTp>B2</docTp>
<totPage>8</totPage>
<docID>B2111</docID>
</docList>
</message>
<Resp>

Is there any idea to generatre like
>>
>> DocSet 1
>> Document type = A1 drop down list with length =
>> totPage (5), onchange to
>> redirect url: http://.....param?docID+docTp
>> Document Type = B1 drop down list with length =
>> totPage (4), onchange to
>> redirect url: http://.....param?docID+docTp>>
>> Document Type = C1 drop down list with length =
>> totPage (7), onchange to
>> redirect url: http://.....param?docID+docTp>>
>>
>> docSet 2
>> Document Type = B2 drop down list with length =
>> totPage (, onchange to
>> redirect url: http://.....param?docID+docTp>>
>>

Also, is it possoble to generate the drop down
>> box

beside the doc type? The
size is from totPage no tag?
>> >>

I confuse on how to generate xslt. Can you give
>> me

some tips how to write
the good xslt by steps




Timothy Ma


 
Reply With Quote
 
 
 
 
Joris Gillis
Guest
Posts: n/a
 
      10-21-2004
> I simple add message/docList/docSet in for each case
> and try by error using docList/totPage or simply totPage but i cannot
> generate the drop box with index
> any idea?
>


Try this:

<?xml version="1.0" ?>
<xsl:stylesheet
xmlnssl="http://www.w3.org/1999/XSL/Transform"
version="1.0">

<xslutput method="html" indent="yes"/>

<xsl:key name="by-docSet" match="docSet" use="."/>

<xsl:template match="Resp">
<html>
<head>
<title/>
</head>
<body>
<xsl:for-each select="message/docList/docSet[generate-id(.) =
generate-id(key('by-docSet', .))]">
<h1>
DocSet <xsl:value-of select="."/>
</h1>
<xsl:for-each select="key('by-docSet', .)">
<p>
Document type
<xsl:value-of select="following-sibling::docTp[1]"/>
<select name="{following-sibling::docTp[1]}"
OnChange="location.href='http://www.yoursite.org/param?{following-sibling::docID[1]}+{following-sibling::docTp[1]}'">
<!-- calling a template to generate <option> tags > -->
<xsl:call-template name="generateDropdown">
<xsl:with-param name="length"
select="following-sibling::totPage[1]" />
</xsl:call-template>
</select>
</p>
</xsl:for-each>
</xsl:for-each>
</body>
</html>
</xsl:template>

<!-- a recursive template to generate <option> tags > -->
<xsl:template name="generateDropdown">
<xslaram name="length" />
<xslaram name="count" select="$length +1"/>
<xsl:if test="$length &gt; 0">
<option value="{$count - $length}"><xsl:value-of
select="$count - $length" /></option>
<xsl:call-template name="generateDropdown">
<xsl:with-param name="length" select="$length -
1"/>
<xsl:with-param name="count" select="$count"/>
</xsl:call-template>
</xsl:if>
</xsl:template>

</xsl:stylesheet>

regards,

--
Joris Gillis (http://www.ticalc.org/cgi-bin/acct-v...i?userid=38041)
Ceterum censeo XML omnibus esse utendum
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Including XSLT/XML document within a XSLT document dar_imiro@hotmail.com XML 4 12-13-2005 02:26 AM
Multiple XSLT Transforms using a Controller XSLT sneill@mxlogic.com XML 2 10-19-2005 11:00 AM
ANN: New low-cost XML Editor, XSLT Editor, XSLT Debugger, DTD/Schema Editor Stylus Studio Java 0 08-03-2004 03:53 PM
xslt alone or xslt/java for static site? ted XML 1 01-26-2004 10:41 AM
[XSLT]Passing values from Javascript to a XSLT variable Benjamin Hillsley XML 3 09-25-2003 04:50 AM



Advertisments