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

[xsl 2.0] counting the nodes in the current group

Subject: [xsl 2.0] counting the nodes in the current group
From: Keith Gilbert <kgilbert@xxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 28 May 2008 16:01:44 -0500
 [xsl 2.0] counting the nodes in the current group
I'm getting up to speed on XSL. Michael Kay's XSL 2.0 and XPath 2.0 Programmer's Reference has been invaluable. I've got my first XSL transform working, but there is one last detail I can't seem to work out.

In the example below, Instead of a "5" in the 'aid:trows="5"' statement in line 10, I need to insert the actual number of occurances of "man_part_no" in the current group. I've been trying some things with the count() function, but can't seem to get it right. I know that count will return the number of items in a sequence, so I assume I'm close to the solution, but I'm stuck. Any help pointing me in the right direction would be appreciated.

01. <!-- group by category -->
02. <xsl:for-each-group select="//Item" group-adjacent="category">
03. <!-- sub-group by type -->
04. <xsl:for-each-group select="current-group()" group- adjacent="type">
05. <!-- test to see if the type is blank or not -->
06. <xsl:choose>
07. <xsl:when test="string(current-grouping-key())">
08. <!-- type is not blank -->
09. <Paragraph aid:pstyle="Table">
10. <Table aid:table="table" aid5:tablestyle="IC table 1" aid:trows="5" aid:tcols="7">
11. <xsl:for-each select="current-group()">
12. <Cell aid:table="cell" aid:crows="1" aid:ccols="1"><xsl:value-of select="man_part_no"/></Cell>
13. </xsl:for-each>
14. </Table>
15. </Paragraph>
16. </xsl:when>
17. </xsl:choose>
18. </xsl:for-each-group>
19. </xsl:for-each-group>

~ Keith

Current Thread


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.
First Name
Last Name
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.