June 2008
Intermediate to advanced
986 pages
27h 8m
English
[2.0]
current-grouping-key()
Returns the value used to select the current group.
xs:anyAtomicType?current-grouping-key()
None.
The value used to select the items in the current group. The
current-grouping-key()
function is only useful inside an <xsl:for-each-group> element with
a group-by or group-adjacent attribute. Calling current-grouping-key() anywhere else
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-grouping-key() 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-grouping-key.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> ...Read now
Unlock full access