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

grouping-problem

Subject: grouping-problem
From: Annina.Hirschi-Wyss@xxxxxxxxxxxx
Date: Thu, 14 Jun 2007 10:59:11 +0200
 grouping-problem
Hi,
I'm working with
XSLT 2
Saxon 8
And I am a newbie with XSLT...

----
Here is the XML file 
"stats.xml"

<statistic>
<class name="CI_Citation" associationName="citation" count="50">
</class>
<class name="CI_Citation" associationName="title" count="100">
</class>
<class name="MD_Metadata" count="300">
</class>
<class name="MD_Metadata" associationName="parentId" count="3">
</class>
<class name="CI_Citation" associationName="citation" count="60">
</class>
<class name="CI_Citation" associationName="title" count="200">
</class>
<class name="MD_Metadata" count="50">
</class>
<class name="MD_Metadata" associationName="parentId" count="10">
</class>
[...]
</statistic>
----

Output should be a csv-textfile like:

CI_Citation		citation	110
			title		300
MD_Metadata				350
			parentId	13
----

I managed quite well, but only did my XSLT not consider the class
MD_Metadata without the "associationName":

"stats.xsl"

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:output encoding="ISO-8859-1"/>
	<xsl:output method="text"/>
<xsl:template match="/">
		<xsl:apply-templates select="statistic"/>
</xsl:template>
[...]
<xsl:for-each-group select="class" group-by="@name">	
  <xsl:value-of select="current-grouping-key()"/>
		<xsl:for-each-group select="current-group()"
group-by="@associationName" >
			<xsl:text>;</xsl:text>
			<xsl:value-of select="current-grouping-key()"/>
			<xsl:text>;</xsl:text>
			<xsl:value-of select="sum(current-group()/@count)"/>
            </xsl:for-each-group>
</xsl:for-each-group>
[...]
----

Is there a possibility to list the class MD_Metadata even if there is no
"associationName"? Thanks for your reply!

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

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