[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Iterating through a subset of the available nodes

Subject: Iterating through a subset of the available nodes
From: "Steve Bruce" <snslinn9@xxxxxxxxxxx>
Date: Wed, 29 Aug 2001 13:59:53 -0500
xsl top10
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



Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.