title: Creating a nested tree structure from a path in XSLT
body: <p>I have a dynamic XML document which represents a tree structure of categories, but does so using path separated attributes <strong>in arbitrary order</strong> - like this:</p>
  
  <pre><code>   &lt;data&gt;    
        &lt;record ID="24" Name="category 1\sub category 1"/&gt;   
        &lt;record ID="26" Name="category 1"/&gt;     
        &lt;record ID="25" Name="category 1\sub category 1\sub category 2"/&gt;    
        &lt;record ID="27" Name="category 1\sub category 1\sub category 3"/&gt;    
        ...
     &lt;/data&gt; 
  </code></pre>
  
  <p>I need to come up with a solution that 'normalizes' the XML so that it is transformed into something like this: </p>
  
  <pre><code>   &lt;data&gt;    
        &lt;record ID="26" Name="category 1"&gt;    
           &lt;record ID="24" Name="sub category 1"&gt;    
              &lt;record ID="25" Name="sub category 2"/&gt;
              &lt;record ID="27" Name="sub category 3"/&gt;    
           &lt;/record&gt;
        &lt;/record&gt;   
        ...
     &lt;/data&gt;
  </code></pre>
  
  <p>Basically I was wondering if this is something XSLT might be able to address, and how, rather than having to do it programmatically.</p>