Hello, I need to have my XSLT stylesheet sort my XML file's child nodes, but only certain ones. Here's an example of what the XML is like:
<?xml version="1.0"?>
<xmltop>
<child1 num="1">
<data>12345</data>
</child1>
<child1 num="2">
<data>12345</data>
</child1>
<child2 num="3">
<data>12345</data>
</child2>
<child2 num="2">
<data>12345</data>
</child2>
<child2 num="1">
<data>12345</data>
</child2>
</xmltop>
And this is the XSL file I'm using:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/xmltop">
<xsl:copy>
<xsl:apply-templates>
<xsl:sort select="@num"/>
</xsl:apply-templates>
</xsl:copy>
</xsl:template>
<xsl:template match="child2">
<xsl:copy-of select="."/>
</xsl:template>
</xsl:stylesheet>
This creates problems for me because the nodes are stripped of their tags, and their contents remain, making my XML invalid. I'm not really an expert at XSL so pardon me if this is a dumb question.
The <child2>
's are sorted properly.
Thank you.