Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

xsl:sort within xsl:for-each

Status
Not open for further replies.

tmryan

Programmer
Dec 22, 2000
73
US
I've been attempting to use an xsl:sort within an xsl:for-each with no luck. Can anyone help me solve this?
I'm using the following xsl that gets called when selecting a Sort button in an HTML page (the xml is a data island)

<charges>
<xsl:for-each select=&quot;transaction&quot; xmlns:xsl=&quot; <xsl:sort select=&quot;amt&quot; order=&quot;ascending&quot; data-type=&quot;number&quot;/>
<transaction>
<xsl:attribute name=&quot;type&quot;><xsl:value-of select=&quot;@type&quot;/>
</xsl:attribute>
<date><xsl:value-of select=&quot;date&quot;/></date>
<vendor><xsl:value-of select=&quot;vendor&quot;/></vendor>
<amt><xsl:value-of select=&quot;amt&quot;/></amt>
</transaction>
</xsl:for-each>
</charges>

The xsl:sort statement cause me to get no output at all. If I remove it - the data is sorted by amount - but in an ascii order - not by value. Here is a small example of the data:

<?xml version=&quot;1.0&quot;?>
<charges>
<transaction type=&quot;credit&quot;>
<date>05/26/01</date>
<vendor>EDDY'S BIKE SHOP</vendor>
<amt>211.49</amt>
</transaction>
<transaction type=&quot;credit&quot;>
<date>05/27/01</date>
<vendor>HOME DEPOT</vendor>
<amt>74.11</amt>
</transaction>
<transaction type=&quot;debit&quot;>
<date>05/27/01</date>
<vendor>HOME DEPOT</vendor>
<amt>4.52</amt>
</transaction>
</charges>

Any ideas?

Thanks
Tim Ryan
 
Hello,
It seems that there's nothing wrong with xsl:sort.
Have you tried
<xsl:for-each select=&quot;//transaction&quot;>
Hope this helps.
D.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top