Super User Asked by Harshi on December 16, 2021
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
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>
Answered by fratester on December 16, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP