title: XML, XSLT transformation and lookup for generated ids
body: <p>I have an xml file and using xslt transformation, I need to generate following xml file.</p>
  
  <pre><code>&lt;root&gt;
      &lt;Entities&gt;
          &lt;Classifications&gt;
              &lt;classificatie UniqueID="1"&gt;
                  &lt;Name&gt;standaard1&lt;/Name&gt;
              &lt;/classificatie&gt;
              &lt;classificatie UniqueID="2"&gt;
                  &lt;Name&gt;bdi&lt;/Name&gt;
              &lt;/classificatie&gt;
              &lt;classificatie UniqueID="3"&gt;
                  &lt;Name&gt;lokaal1&lt;/Name&gt;
              &lt;/classificatie&gt;
          &lt;/Classifications&gt;
          &lt;Categories&gt;
              &lt;categorie UniqueID="1" id="D0001" super-id="" volgnummer=""&gt;
                  &lt;Name&gt;Beleid vast-/opstellen en Bestuur&lt;/Name&gt;
              &lt;/categorie&gt;
              &lt;categorie UniqueID="2" id="D0002" super-id="" volgnummer=""&gt;
                  &lt;Name&gt;Beleid uitvoeren&lt;/Name&gt;
              &lt;/categorie&gt;
              &lt;categorie UniqueID="3" id="D0003" super-id="" volgnummer=""&gt;
                  &lt;Name&gt;Beheer en Handhaving&lt;/Name&gt;
              &lt;/categorie&gt;
          &lt;/Categories&gt;
      &lt;/Entities&gt;
      &lt;Relations&gt;
          &lt;Classification_Category ClassficationID="1" CategoryID="2" /&gt;
      &lt;/Relations&gt;
  &lt;/root&gt;
  </code></pre>
  
  <p>Using xslt transformation, I am able to generate the entities node. To generate the relations node, I need to generated UniqueID. 
  The generated uniqueID for elements in entity node are not present in original xml file but generated using XSL file.
  For generating the unique id following XSLT code is used ..</p>
  
  <pre><code>&lt;xsl:template match="classificatie"&gt;
      &lt;xsl:variable name="vNum1"&gt;
          &lt;xsl:number level="any" count="classificatie"/&gt;
      &lt;/xsl:variable&gt;
      &lt;classificatie&gt;
          &lt;xsl:attribute name="UniqueID"&gt;
              &lt;xsl:value-of select="$vNum1"/&gt;
          &lt;/xsl:attribute&gt;
          &lt;Name&gt;
              &lt;xsl:value-of select="@id"/&gt;
          &lt;/Name&gt;
      &lt;/classificatie&gt;
  &lt;/xsl:template&gt;
  </code></pre>
  
  <p>For Categorie also, XLST template is similar to classificate template. In original XML file categorie node is nested under classificatie element.</p>
  
  <p>In newly generated XML, I need to make it separate elements under entieties elements. And the relation between these needs to be established under "Relations" elements.</p>
  
  <p>I am able to generate the nodes as separate node under entities. And i am not able to generate elements under "Relations" node using newly generated ids.</p>
  
  <p><strong>In short : Converting parent-child relation (nested relation) with non-nested elements.</strong>
  -Rajesh</p>
  
  <p>The source XML and xslt files are zipped at following location
  <a href="http://cid-2b9bf77533900b84.office.live.com/self.aspx/.Public/XML-XSLT.zip" rel="nofollow">Zip Files</a></p>
  
  <p><strong>Update from link</strong>: Reduce input sample</p>
  
  <pre><code>&lt;root&gt;
    &lt;classificaties&gt;
      &lt;classificatie id="standard"&gt;
        &lt;categorieen&gt;
          &lt;categorie id="D0001" super-id=""&gt;Category1&lt;/categorie&gt;
          &lt;categorie id="D0002" super-id=""&gt;Category2&lt;/categorie&gt;
          &lt;categorie id="D0003" super-id=""&gt;Category3&lt;/categorie&gt;
          &lt;categorie id="D0004" super-id="D0001"&gt;Category1.1&lt;/categorie&gt;
          &lt;categorie id="D0005" super-id="D0001"&gt;Category1.2&lt;/categorie&gt;
          &lt;categorie id="D0007" super-id="D0002"&gt;Category2.1&lt;/categorie&gt;
          &lt;categorie id="D0021" super-id="D0003"&gt;Category3.1&lt;/categorie&gt;
          &lt;categorie id="D0025" super-id="D0002"&gt;Category2.2&lt;/categorie&gt;
        &lt;/categorieen&gt;
      &lt;/classificatie&gt;
      &lt;classificatie id="bdi"&gt;
        &lt;categorieen&gt;
          &lt;categorie id="MLF0000002" 
                     super-id="" volgnummer="1"&gt;Test 1&lt;/categorie&gt;
          &lt;categorie id="MLF0000003" 
                     super-id="" volgnummer="2"&gt;Test 2&lt;/categorie&gt;
          &lt;categorie id="MLF0000017" 
                     super-id="MLF0000003" volgnummer="1"&gt;Test 17&lt;/categorie&gt;
          &lt;categorie id="MLF0000020" 
                     super-id="MLF0000002" volgnummer="2"&gt;Test 20&lt;/categorie&gt;
          &lt;categorie id="MLF0000021" 
                     super-id="MLF0000002" volgnummer="3"&gt;Test 21&lt;/categorie&gt;
          &lt;categorie id="MLF0000025" 
                     super-id="MLF0000003" volgnummer="2"&gt;Test 25&lt;/categorie&gt;
          &lt;categorie id="MLF0000027" 
                     super-id="MLF0000003" volgnummer="3"&gt;Test 27&lt;/categorie&gt;
          &lt;categorie id="MLF0000030" 
                     super-id="MLF0000003" volgnummer="4"&gt;Test 30&lt;/categorie&gt;
          &lt;categorie id="MLF0000031" 
                     super-id="MLF0000003" volgnummer="5"&gt;Test 31&lt;/categorie&gt;
        &lt;/categorieen&gt;
      &lt;/classificatie&gt;
    &lt;/classificaties&gt;
  &lt;/root&gt;
  </code></pre>