June 2008
Intermediate to advanced
986 pages
27h 8m
English
[2.0] current-group()
Returns all the items that are included in the current group.
item()*current-group()
None.
The set of items that are included in the current group.
This function is only useful inside the <xsl:for-each-group> element.
Calling current-group()
outside <xsl:for-each-group>
returns the empty sequence.
XSLT 2.0 section 14, “Grouping.”
We’ll use a simplified version of our address book document
to illustrate the current-group() function:
<?xml version="1.0"?>
<!-- simple-addresses.xml -->
<addressbook>
<address>
<name>Mr. Chester Hasbrouck Frisby</name>
<city>Sheboygan</city>
<state>WI</state>
</address>
<address>
<name>Mary Backstayge</name>
<city>Skunk Haven</city>
<state>MA</state>
</address>
<address>
<name>Ms. Natalie Attired</name>
<city>Winter Harbor</city>
<state>ME</state>
</address>
<address>
<name>Harry Backstayge</name>
<city>Skunk Haven</city>
<state>MA</state>
</address>
<address>
<name>Mary McGoon</name>
<city>Boylston</city>
<state>VA</state>
</address>
<address>
<name>Ms. Amanda Reckonwith</name>
<city>Lynn</city>
<state>MA</state>
</address>
</addressbook>We’ll group these names by <state> with this
stylesheet:
<?xml version="1.0"?>
<!-- current-group.xsl --> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="text"/> <xsl:template match="/"> <xsl:text>
Here's a test of the </xsl:text> <xsl:text>current-group() function:
</xsl:text> <xsl:text>
 Customers ...Read now
Unlock full access