I'm using the following XSLT,but the order of nodes after sorting is a bit problem for me as they are not following the same order as of the input.
enter code here
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="Types">
<xsl:sort select="Type1"/>
</xsl:apply-templates>
<xsl:apply-templates select="SecondTypes">
<xsl:sort select="Type1"/>
</xsl:apply-templates>
<xsl:ap开发者_StackOverflow中文版ply-templates select="ServiceOption">
<xsl:sort select="Issue"/>
</xsl:apply-templates>
<xsl:apply-templates select="ServiceConcession">
<xsl:sort select="Concession" data-type="number"/>
</xsl:apply-templates>
<xsl:apply-templates select="node()[not(self::Types|self::SecondTypes|self::ServiceOption|self::ServiceConcession)]|@*"/>
</xsl:copy>
</xsl:template>
Just modify the identity transformation so that sort is applied to the wanted nodes only:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="Types">
<xsl:sort select="Type1"/>
</xsl:apply-templates>
<xsl:apply-templates select="node()[not(self::Types)]|@*"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
精彩评论