1

Sort XML with xsd format in ascending order

Because of xsd format in XML my xslt solution was not working ,what must be used in case of xsd?

Here is my XML Input:

4 1 7 What I tried:

<xsl:stylesheet version="1.0" xmlns:xsl="w3.org/1999/XSL/Transform"> <xsl:template match="/*"> xsl:copy xsl:apply-templates <xsl:sort select="number"/> </xsl:apply-templates> </xsl:copy> </xsl:template>

<xsl:template match="@*|node()">
    <xsl:copy>
        <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
</xsl:template>

</xsl:stylesheet> What i expect as Output:

1 4 7
Harshi
  • 11
  • 1

1 Answers1

0

I think you want something close to this (leaving out the namespace and other declarations around):

<xsl:template match="/">
  <xsl:element name="test">
    <xsl:for-each select="//number">
      <xsl:sort select="text(.)" data-type="number"/>
      <xsl:copy-of select="." />
    </xsl:for-each>
  </xsl:element>
</xsl:template>
fratester
  • 364
  • 1
  • 3