Project

Profile

Help

Bug #2003 ยป composite_grouping_key.xsl

David Rudel, 2014-02-11 13:29

 
<?xml version="1.0" encoding="UTF-8" ?>

<xsl:stylesheet version="3.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xdt="http://www.w3.org/2005/xpath-datatypes"
xmlns:saxon="http://saxon.sf.net/"
exclude-result-prefixes="xs xdt xdt saxon">

<xsl:variable name="doc">
<a>
<b color="blue">
<object quantity="3"/>
<object quantity="1"/>
<object quantity="2"/>
<object quantity="3"/>
<object quantity="3"/>
</b>
<b color="red">
<object quantity="1"/>
<object quantity="2"/>
<object quantity="3"/>
<object quantity="3"/>
</b>
</a>
</xsl:variable>

<xsl:template match="/">
<xsl:for-each-group select="$doc//object" group-by="@quantity,../@color" composite="yes">
<xsl:text>
</xsl:text>
<group key="{current-grouping-key()}" key.count="{count(current-grouping-key())}" group.size="{count(current-group())}"/>
</xsl:for-each-group>
</xsl:template>

</xsl:stylesheet>
    (1-1/1)