In my XSLT, I have something like:
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" encoding="UTF-8" omit-xml-declaration="yes"/>
<xsl:template match="PhyscianTotals" name="PhyscianTotals">
<xsl:for-each select="PhysicianTotals">
<xsl:for-each-group select="Statistic" group-by="Type">
<xsl:if test="Title='PHYSICIAN DETAIL TOTAL'">
<xsl:element name="totals">
</xsl:element>
</xsl:if>
</xsl:for-each-group>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Is this valid XSLT? Specifically, the section of "xsl:if within the xsl:for-each-group". One of the XSLT compilation tool we call always error out stating: xsl:if is not allowed at this position in the stylesheet. If I remove the xsl:for-each-group, it passes. I am not sure if it's my xslt having errors or if it's the compilation tool.
Turns out our tool only support XSLT 1.0. So I guess I am back to rewrite the XSLT using 1.0 tags only.
The original XML looks like:
<?xml version="1.0" encoding="UTF-8"?>
<PhysicianTotals>
<Statistic>
<Title>PHYSICIAN TOTAL</Title>
<Type>Type 1</Type>
<Key>Cases</Key>
<Value>1</Value>
</Statistic>
<Statistic>
<Title>PHYSICIAN TOTAL</Title>
<Type>Type 1</Type>
<Key>Percentage</Key>
<Value>25.0%</Value>
</Statistic>
<Statistic>
<Title>PHYSICIAN TOTAL</Title>
<Type>Type 2</Type>
<Key>Cases</Key>
<Value>3</Value>
</Statistic>
<Statistic>
<Title>PHYSICIAN TOTAL</Title>
<Type>Type 1</Type>
<Key>Percentage</Key>
<Value>75.0%</Value>
</Statistic>
</PhysicianTotals>
And the output will look like:
<?xml version="1.0" encoding="UTF-8"?>
<totals>
<type>PHY_DETAIL</type>
<detailInfo>
<code>Type 1</code>
</detailInfo>
<count>
<caseValue>1</caseValue>
<percentValue>25.0%</percentValue>
</count>
</totals>
<totals>
<type>PHY_DETAIL</type>
<detailInfo>
<code>Type 2</code>
</detailInfo>
<count>
<caseValue>3</caseValue>
<percentValue>75.0%</percentValue>
</count>
</totals>