Tag - XSL

How to sort a whole XML document using XSL

This is a variation of an identity transformation that sorts all nodes and attributes alphabetically.<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output indent="yes"> <xsl:output method="xml" omit-xml-declaration="no"> <xsl:template match="@*|node()" priority="1"> <xsl:copy> <xsl:apply-templates select="@*|node()"> <xsl:sort data-type="text" order="ascending" select="name()"> </xsl:sort></xsl:apply-templates> </xsl:copy></xsl:template> </xsl:output></xsl:output></xsl:stylesheet>

Get XPath of an XML node

There are lots of XSL templates out there that get a human readable path to a node. But none of them cover the case when there are more than one node of the same element at the same level.Please find below the code that get XPath of an XML node:<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output...