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!
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--