|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Grouping based on child value
Hi all,
Here is my XML:
<?xml version="1.0" encoding="UTF-8"?>
<root>
<record>
<col1>PG</col1>
</record>
<record>
<col1>1</col1>
</record>
<record>
<col1>2</col1>
</record>
<record>
<col1>PG</col1>
</record>
<record>
<col1>3</col1>
</record>
<record>
<col1>4</col1>
</record>
</root>
I want to group all of the <record> elements, starting with
col1[starts-with(.,'PG')]. I am expecting 2 groups of 3 record elements
each. Here is my style sheet:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs"
version="3.0" expand-text="yes">
<xsl:output indent="yes"/>
<xsl:template match="root">
<xsl:copy>
<xsl:message
select="count(record[col1[starts-with(.,'PG')]])"></xsl:message>
<xsl:for-each-group select="record"
group-starting-with="descendant::col1[.='PG']">
<group></group>
</xsl:for-each-group>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
However, my result is a single group:
<?xml version="1.0" encoding="UTF-8"?>
<root>
<group/>
</root>
Any help would be appreciated. Thank you.
Rick Quatro
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








