grouping and result-document help
I'm using XSLT 2.0 and Saxon 9B.
I process xml files present in two directories and produce the output xml files, through result-document(). This is done by passing a parameter (<AIDtype> element value). I tried to use for-each-group, but I can't get the needed output.
For IPCC as parameter value,
1st input xml:
<?xml version="1.0" encoding="UTF-8"?>
<Section>
<Chapter>
<Chapter><Head>IPCC</Head>
<test><Head>IPCC Provisioning</Head>
<Feature>IPCC-Prov</Feature>
<AIDType>IPCC</AIDType>
<SectionID>0001</SectionID>
<check cmdType = "Create"><Head></Head></check>
<check cmdType = "Retrieve"><Head></Head></check></test>
<test><Head>IPCC Alarm Provisioning</Head>
<Feature>IPCC-Alarms</Feature>
<AIDType>IPCC</AIDType>
<SectionID>0001</SectionID>
<check cmdType = "Set"><Head></Head></check>
<check cmdType = "Retrieve"><Head></Head></check>
</test></Chapter></Chapter></Section>
2nd input file:
<?xml version="1.0" encoding="UTF-8"?>
<Section><Chapter><Head>Neighbour Discovery</Head>
<Chapter><Head>IPCC</Head>
<test><Head>IPCC Provisioning</Head>
<Feature>IPCC-Prov</Feature>
<AIDType>IPCC</AIDType>
<ratttable>
<rattrow attrfield = "1">
<rattcell><TL1Commands cmdType = "Create">M</TL1Commands></rattcell>
<rattcell><TL1Commands cmdType = "Retrieve">O</TL1Commands></rattcell>
</rattrow>
</ratttable></test>
<test><Head>IPCC Provisioning</Head>
<Feature>IPCC-Alarms</Feature>
<AIDType>IPCC</AIDType>
<ratttable>
<rattrow attrfield = "1">
<rattcell><TL1Commands cmdType = "Set">M</TL1Commands></rattcell>
<rattcell><TL1Commands cmdType = "Retrieve">O</TL1Commands></rattcell>
</rattrow>
</ratttable></test>
</Chapter></Chapter></Section>
XSL:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:param name="repoDirectory"/>
<xsl:param name="implDirectory"/>
<xsl:param name="implAIDTypeTag"/>
<xsl:output indent="yes" method="xml" version="1.1"/>
<xsl:variable name="implSubTree" select="collection(concat($implDirectory,'/?select=*.xml'))"/>
<xsl:variable name="repoSubTree" select="collection(concat($repoDirectory,'/?select=*.xml'))"/>
<xsl:template match="/">
<xsl:apply-templates select="$implSubTree//test[.//AIDType = $implAIDTypeTag]" mode="doNE"/>
</xsl:template>
<xsl:template match="test" mode="doNE">
<xsl:variable name="Feature" select="Feature"/>
<xsl:variable name="repoSection" select="$repoSubTree//test[./AIDType = $implAIDTypeTag][./Feature = $Feature]"/>
<xsl:variable name="implSection" select="."/>
<xsl:variable name="AIDType" select="./AIDType"/>
<xsl:for-each-group select="check" group-by="@cmdType">
<xsl:variable name="file" select="concat(@cmdType, '-',$Feature,'.xml')"></xsl:variable>
<xsl:result-document href="{$file}">
<xsl:apply-templates select="current-group()">
<xsl:with-param name="repoSection" select="$repoSection"/>
<xsl:with-param name="implSection" select="$implSection"/>
</xsl:apply-templates>
</xsl:result-document>
</xsl:for-each-group>
</xsl:template>
<xsl:template match="check">
blah blah
</xsl:template>
</xsl:stylesheet>
When I use the above stylesheet model, i can group by @cmdType w.r.t. <Feature>. Because of this I get two xml files, namely Retrieve-IPCC-Alarms.xml and Retrieve-IPCC-Prov.xml. I need to group all under same @cmdType.
The total output files should be Retrieve.xml, Create.xml and Set.xml only. But if I use the above type of grouping I get 4 output files. Is there any way? Any help is appreciated.
------
Rummy
__________________
Rummy
|