I have been through many similar questions and XSLT tutorials but still I am unable to figure out how XSLT works.Below is the XML that I want sort :-\[code\]<?xml version="1.0" encoding="UTF-8"?><xliff xmlns="urnasis:names:tc:xliff:document:1.1" version="1.1"><file product="mxn" source-language="en"><body><!-- Menu --> <msg-unit id="Menu.PerformTask"> <msg>Perform Task</msg> <note>When selected performs a task.</note> </msg-unit> <msg-unit id="Menu.Add"> <msg>Add New</msg> <note>When selected Adds a new row.</note> </msg-unit></body></file></xliff>\[/code\]Expected output is:-\[code\]<?xml version="1.0" encoding="UTF-8"?><xliff xmlns="urnasis:names:tc:xliff:document:1.1" version="1.1"><file product="mxn" source-language="en"><body><!-- Menu --> <msg-unit id="Menu.Add"> <msg>Add New</msg> <note>When selected Adds a new row.</note> </msg-unit> <msg-unit id="Menu.PerformTask"> <msg>Perform Task</msg> <note>When selected performs a task.</note> </msg-unit></body></file></xliff>\[/code\]The \[code\]<msg-unit>\[/code\] tags needs to be sorted based on the value of their \[code\]id\[/code\] attributes. Other tags (like the comments) should be where-ever they were.I tried so many combinations but I have no clue about XSLT. Below is what was my last attempt.\[code\]<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> <xslutput method="xml" indent="yes" /> <xsl:template match="/"> <xsl:copy-of select="*"> <xsl:apply-templates> <xsl:sort select="attribute(id)" /> </xsl:apply-templates> </xsl:copy-of> </xsl:template></xsl:stylesheet>\[/code\]This one simply spits out whatever XML it got, without any sorting.