title: How to control the order of elements generation in xsl
body: <p>I am quite new to XSLT. And hence I am facing some difficulties .I have to transform a fairly large XML into a new XML . However , the way I am heading , I am facing some difficulties :</p>
  
  <p>The input XML could be like :</p>
  
  <pre><code>&lt;Employees&gt;
    &lt;Employee&gt;
      &lt;Name&gt;A&lt;/Name&gt;
      &lt;Role&gt;Manager&lt;/Role&gt;
      &lt;Salary&gt;5000$&lt;/Salary&gt;
    &lt;/Employee&gt;
    &lt;Employee&gt;
      &lt;Name&gt;A&lt;/Name&gt;
      &lt;Role&gt;Director&lt;/Role&gt;
      &lt;Salary&gt;8000$&lt;/Salary&gt;
    &lt;/Employee&gt;
  &lt;/Employees&gt;
  </code></pre>
  
  <p>and the output XML should be like :</p>
  
  <pre><code> &lt;Manager&gt;
        &lt;Employee_Name&gt;A&lt;/Employee_Name&gt;
   &lt;/Manager&gt;
   &lt;Count_Of_Employee&gt;2&lt;/Count_Of_Employee&gt;
   &lt;Director&gt;
        &lt;Employee_Name&gt;B&lt;/Employee_Name&gt;
   &lt;/Director&gt;
  </code></pre>
  
  <p>Now If , I will apply the template <code>&lt;xsl:Employees/Employee&gt;</code> ,then it will check for every employee and will create the Director tag just after Manager Tag . </p>
  
  <p>Hence on running the validation against the XSD , it will fail, as it expect to have a coutn tag in between .</p>
  
  <p>So my first question is: how can I control the order of the output element nodes while writing up a generic template ?</p>
  
  <p>My other question is: I have to transform a large XML, so I don't want to write <code>&lt;xsl:element&gt;</code> each time i am generating a tag .. </p>
  
  <p>I tried to search various generic templates .. but couldn't find or write a good generic template for generating an element for which the tag name (in the target xml) are not the same as the one( in source XML) [ I found various generic templates for which element name is same in both the XMLs].  </p>
  
  <p>Can someone please help me on that .. 
  I have looked in the XSL standard libraray as well .. but could not find a good alternative .. </p>
  
  <p>Any suggestion or soultion would be a great help to me.</p>