M
Mike King
I don't know how to group the following data in the way I want it. I want
the output of the transformation to be "5678". Does anyone know what I am
doing worry?
<?xml version="1.0"?>
<data>
<unit sn="5">
<test-a>
<result id="0">5</result>
</test-a>
<test-a>
<result id="1">6</result>
</test-a>
<test-b>
<result id="0">10</result>
</test-b>
</unit>
<unit sn="6">
<test-a>
<result id="1">8</result>
</test-a>
<test-a>
<result id="0">7</result>
</test-a>
<test-b>
<result id="0">11</result>
</test-b>
</unit>
</data>
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt">
<xslutput method="text" />
<xsl:template match="unit[1]">
<xsl:apply-templates select="test-a" />
</xsl:template>
<xsl:template match="unit">
<xsl:variable name="my-sort">
<xsl:for-each select="/data/unit[1]/test-a/result">
<xsl:value-of select="@id" />
</xsl:for-each>
</xsl:variable>
<xsl:apply-templates select="test-a">
<xsl:sort
select="count(msxsl:node-set($my-sort)/*[string()=string(current()/result/@id)]/preceding-sibling::*)"
data-type="number" />
</xsl:apply-templates>
</xsl:template>
</xsl:stylesheet>
the output of the transformation to be "5678". Does anyone know what I am
doing worry?
<?xml version="1.0"?>
<data>
<unit sn="5">
<test-a>
<result id="0">5</result>
</test-a>
<test-a>
<result id="1">6</result>
</test-a>
<test-b>
<result id="0">10</result>
</test-b>
</unit>
<unit sn="6">
<test-a>
<result id="1">8</result>
</test-a>
<test-a>
<result id="0">7</result>
</test-a>
<test-b>
<result id="0">11</result>
</test-b>
</unit>
</data>
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt">
<xslutput method="text" />
<xsl:template match="unit[1]">
<xsl:apply-templates select="test-a" />
</xsl:template>
<xsl:template match="unit">
<xsl:variable name="my-sort">
<xsl:for-each select="/data/unit[1]/test-a/result">
<xsl:value-of select="@id" />
</xsl:for-each>
</xsl:variable>
<xsl:apply-templates select="test-a">
<xsl:sort
select="count(msxsl:node-set($my-sort)/*[string()=string(current()/result/@id)]/preceding-sibling::*)"
data-type="number" />
</xsl:apply-templates>
</xsl:template>
</xsl:stylesheet>