MrTom --
First, thank you for the tip.
I've been playing with it all morning and not getting anywhere. I see exactly how it is supposed to be working, and it makes perfect sense, but I am stuck on a runtime error "variable or parameter 'sorted' must evaluate to a node list"
I thought I would move this out of the original thread and see if we can play with it and come up with the solution.
Here's a code snipped for it which produces the error listed above on the <xsl:for-each select="$sorted/Item"> statement. It would appear that $sorted is either a null set or is not evaluating to a node list at a minimum.
<Data>
<Item>
<Name value="R"/>
<Attribute value="123"/>
</Item>
<Item>
<Name value="D"/>
<Attribute value="ABC"/>
</Item>
<Item>
<Name value="X"/>
<Attribute value="QRS"/>
</Item>
<Item>
<Name value="A"/>
<Attribute value="XSL"/>
</Item>
</Data>
<xsl:template match="/">
<xsl:variable name="sorted">
<xsl:for-each select="Item">
<xsl:sort select="Name/@value"/>
<xsl:copy-of select="."/>
</xsl:for-each>
</xsl:variable>
<xsl:for-each select="$sorted/Item">
<xsl:value-of select="Name/@value"/> --
<xsl:value-of select="Attribute/@value"/>
</xsl:for-each>
</xsl:template>
I've played with this for the last couple of hours and don't seem to be getting anywhere. Looks like the learning curve is still biting my butt.
First, thank you for the tip.
I've been playing with it all morning and not getting anywhere. I see exactly how it is supposed to be working, and it makes perfect sense, but I am stuck on a runtime error "variable or parameter 'sorted' must evaluate to a node list"
I thought I would move this out of the original thread and see if we can play with it and come up with the solution.
Here's a code snipped for it which produces the error listed above on the <xsl:for-each select="$sorted/Item"> statement. It would appear that $sorted is either a null set or is not evaluating to a node list at a minimum.
<Data>
<Item>
<Name value="R"/>
<Attribute value="123"/>
</Item>
<Item>
<Name value="D"/>
<Attribute value="ABC"/>
</Item>
<Item>
<Name value="X"/>
<Attribute value="QRS"/>
</Item>
<Item>
<Name value="A"/>
<Attribute value="XSL"/>
</Item>
</Data>
<xsl:template match="/">
<xsl:variable name="sorted">
<xsl:for-each select="Item">
<xsl:sort select="Name/@value"/>
<xsl:copy-of select="."/>
</xsl:for-each>
</xsl:variable>
<xsl:for-each select="$sorted/Item">
<xsl:value-of select="Name/@value"/> --
<xsl:value-of select="Attribute/@value"/>
</xsl:for-each>
</xsl:template>
I've played with this for the last couple of hours and don't seem to be getting anywhere. Looks like the learning curve is still biting my butt.