sort list node
Posted: Fri Jun 11, 2004 2:08 pm
hi,
i need to send as a param a sorted list of subnodes.
the xsl looks like this:
<xsl:for-each select="//branch[@level=$maxlevel - 1]">
<tr>
<xsl:for-each select="ancestor-or-self::*/shortdescription">
<td>
<xsl:value-of select="." />
</td>
</xsl:for-each>
<xsl:call-template name="mainfillTDfield">
<xsl:with-param name="nodelist" select="branch" />
<xsl:with-param name="pos" select="1" />
</xsl:call-template>
</tr>
</xsl:for-each>
what i want is to sort the nodelist by id of the last level branch:
and the corresponding xml is as follows:
<treedata xsi:noNamespaceSchemaLocation="C:\installaxiom\axiom_app\class\viewer.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<branch branchtype="exposure_level" level="1">
<shortdescription>Greater___than_500K</shortdescription>
<longdescription>Greater___than_500K</longdescription>
<id/>
<branch branchtype="app_book_name" level="2">
<shortdescription>CANADIAN ALBERTA GAS BOOK ALBERTA</shortdescription>
<longdescription>CANADIAN ALBERTA GAS BOOK ALBERTA</longdescription>
<id/>
<branch branchtype="book_app_code" level="3">
<shortdescription>C_GAS_ALTA</shortdescription>
<longdescription>C_GAS_ALTA</longdescription>
<id/>
<branch branchtype="book_name" level="4">
<shortdescription>ALBERTA</shortdescription>
<longdescription>ALBERTA</longdescription>
<id/>
<branch branchtype="trader_name" level="5">
<shortdescription>Jeff Peacock</shortdescription>
<longdescription>Jeff Peacock</longdescription>
<id>5</id>
<field fieldcode="declined_qty">106093901.0</field>
<field fieldcode="exposure_mtm_amt">0.0</field>
<field fieldcode="monthly_qty">106093901.0</field>
</branch>
<branch branchtype="trader_name" level="5">
<shortdescription>PEACOCK</shortdescription>
<longdescription>PEACOCK</longdescription>
<id>2</id>
<field fieldcode="declined_qty">20272157.0</field>
<field fieldcode="exposure_mtm_amt">0.0</field>
<field fieldcode="monthly_qty">20272157.0</field>
</branch>
.....
</branch>
......
</branch>
....
</branch>
......
</branch>
......
</treedata>
i tried to put the sort element in the for-each as follows:
<xsl:sort select="branch/id" data-type="number"/>
this doesn't work.
any ideas ?
thankx
miraodb
i need to send as a param a sorted list of subnodes.
the xsl looks like this:
<xsl:for-each select="//branch[@level=$maxlevel - 1]">
<tr>
<xsl:for-each select="ancestor-or-self::*/shortdescription">
<td>
<xsl:value-of select="." />
</td>
</xsl:for-each>
<xsl:call-template name="mainfillTDfield">
<xsl:with-param name="nodelist" select="branch" />
<xsl:with-param name="pos" select="1" />
</xsl:call-template>
</tr>
</xsl:for-each>
what i want is to sort the nodelist by id of the last level branch:
and the corresponding xml is as follows:
<treedata xsi:noNamespaceSchemaLocation="C:\installaxiom\axiom_app\class\viewer.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<branch branchtype="exposure_level" level="1">
<shortdescription>Greater___than_500K</shortdescription>
<longdescription>Greater___than_500K</longdescription>
<id/>
<branch branchtype="app_book_name" level="2">
<shortdescription>CANADIAN ALBERTA GAS BOOK ALBERTA</shortdescription>
<longdescription>CANADIAN ALBERTA GAS BOOK ALBERTA</longdescription>
<id/>
<branch branchtype="book_app_code" level="3">
<shortdescription>C_GAS_ALTA</shortdescription>
<longdescription>C_GAS_ALTA</longdescription>
<id/>
<branch branchtype="book_name" level="4">
<shortdescription>ALBERTA</shortdescription>
<longdescription>ALBERTA</longdescription>
<id/>
<branch branchtype="trader_name" level="5">
<shortdescription>Jeff Peacock</shortdescription>
<longdescription>Jeff Peacock</longdescription>
<id>5</id>
<field fieldcode="declined_qty">106093901.0</field>
<field fieldcode="exposure_mtm_amt">0.0</field>
<field fieldcode="monthly_qty">106093901.0</field>
</branch>
<branch branchtype="trader_name" level="5">
<shortdescription>PEACOCK</shortdescription>
<longdescription>PEACOCK</longdescription>
<id>2</id>
<field fieldcode="declined_qty">20272157.0</field>
<field fieldcode="exposure_mtm_amt">0.0</field>
<field fieldcode="monthly_qty">20272157.0</field>
</branch>
.....
</branch>
......
</branch>
....
</branch>
......
</branch>
......
</treedata>
i tried to put the sort element in the for-each as follows:
<xsl:sort select="branch/id" data-type="number"/>
this doesn't work.
any ideas ?
thankx
miraodb