Subject: [xsl] Iterating through a subset of the available nodes From: "Steve Bruce" <snslinn9@xxxxxxxxxxx> Date: Wed, 29 Aug 2001 13:59:53 -0500 |
I am attempting to create a top ten list from a list of 10 or more items. In my example, I have the following XML:
<acct acct_id="2601956" mkt_val="100"> <dtl col_id="1">ABC</dtl> <dtl col_id="2">100</dtl>
This block is repeated numerous times with different values. For my output, I want to create a top ten list for a specific account that is sorted by mkt_val. It would look something like:
<xsl:variable name="acct_id" select="2601956"/> <xsl:for-each select="//acct[@acct_id=$acct_id]"> <xsl:variable name="mkt_val" select="@mkt_val"/> <xsl:sort select="@mkt_val" data-type="number" order="descending"/> <xsl:call-template name="top10"> <xsl:with-param name="times" select="10"/> </xsl:call-template>
<xsl:param name="times"/> <xsl:if test="$times > 0">
<tr valign="top"> <td align="left"><xsl:value-of select="./dtl[@col_id=1]"/></td> <td align="right"><xsl:value-of select="format-number(./dtl[@col_id=2],'###,###,###,###,##0.00')"/></td> </tr>
<xsl:call-template name="top10"> <xsl:with-param name="times" select="$times - 1"/> </xsl:call-template>
Of course, this doesn't work. In this scenario, I receive all the //acct/dtl rows 10 times. Do you know how I can iterate through these nodes just 10 times returning only the top ten sorted values?
Thanks, Steve
_________________________________________________________________ Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Replacing all Occurences of a, Roger | Thread | RE: [xsl] Iterating through a subse, Chris Bayes |
RE: [xsl] Mailto problem, Julian Reschke | Date | RE: [xsl] Iterating through a subse, Chris Bayes |
Month |