I am trying to sort an xml using xsl. Got some sample from xml.com. Its seems logical and intuitive. I tried, some how its not sorting. Its hard getting my head around this.
Here is the Xsl I am using for sorting
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
>
    <xsl:output method="xml" indent="yes"/>
 <xsl:template match="SharePointSites">
  <xsl:copy>
   <xsl:apply-templates>
    <xsl:sort select="Document/@Name"/>
   </xsl:apply-templates>
  </xsl:copy>
 </xsl:template>
 <xsl:template match="*">
  <xsl:copy>
   <xsl:apply-templates/>
  </xsl:copy>
 </xsl:template>
</xsl:stylesheet>
Below, is the XML I am trying to sort. Output is also the same. Its not obvious missing of hierarchy of tags. As I understand from xml.com sample, I have also tried specifying complete hierarchy of tags using match and select tags above.
 <SharePointSites>
<Site Url="http://workspace.imperial.ac.uk/Activities/default.aspx" Name="Activities">
<Directory Name="Public">
<Document Url="http://workspace.imperial.ac.uk/Activities/Public/Imperial Activities Limited reg no etc.doc" Name="Imperial Activities Limited reg no etc.doc"/>
<Document Url="http://workspace.imperial.ac.uk/Activities/Public/Property Enqiry Form.DOC" Name="Property Enqiry Form.DOC"/>
<Document Url="http://workspace.imperial.ac.uk/Activities/Public/New Property Enquiry Form.doc" Name="New Property Enquiry Form.doc"/>
<Document Url="http://workspace.imperial.ac.uk/Activities/Public/52 Princes Gardens.pdf" Name="52 Princes Gardens.pdf"/>
<Document Url="http://workspace.imperial.ac.uk/Activities/Public/Silwood Web site Photo's.ppt" Name="Silwood Web site Photo's.ppt"/>
<Document Url="http://workspace.imperial.ac.uk/Activities/Public/Service charge.pdf" Name="Service charge.pdf"/>
<Document Url="http://workspace.imperial.ac.uk/Activities/Public/SPIP-G.pdf" Name="SPIP-G.pdf"/>
<Document Url="http://workspace.imperial.ac.uk/Activities/Public/Silwood Business Park pictures.doc" Name="Silwood Business Park pictures.doc"/>
</Directory>
<Directory Name="Internal"/>
</Site>
</SharePointSites>
outup is still same. Here is how I am applying transform on XML document.
XslCompiledTransform myXslTrans = new XslCompiledTransform();
            //load the Xsl 
            myXslTrans.Load(@"C:\My code\dotNet Development\SharepointXML\WebService1\SharepointSiteContent.xslt");                
            //do the actual transform of Xml document
            myXslTrans.Transform(aDoc, null, TransformedxmlWriter);
            // Set to document
            aTransforemdDoc.InnerXml = aTransformedStrbulider.ToString();