|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Iterating through a subset of the available nodes
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> </acct> 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: ABC??? 100 And, so on... My first pass at solving this, I tried the code below: <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:for-each> <xsl:template name="top10"> ?<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> ?</xsl:if> </xsl: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 XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








