title: Check if XML has two different types of element node how to bring it in output XML using XSLT
body: <p>I already have an input XML </p>
  
  <pre><code>&lt;tutorial&gt;
  &lt;lessons&gt;
  &lt;lesson&gt;
       chapter1 unit 1 page1
  &lt;/lesson&gt;
  &lt;lesson&gt;
       unit 1 
  &lt;/lesson&gt;
  &lt;/lessons&gt;
  &lt;/tutorial&gt;
  </code></pre>
  
  <p>The output should be </p>
  
  <pre><code>&lt;Geography&gt;
  &lt;historical&gt;
      &lt;social&gt;
         &lt;toc1&gt;
       &lt;toc&gt;
        &lt;chapter&gt;
      chapter1
        &lt;chapter&gt;
        &lt;unit&gt;
      unit 1
        &lt;/unit&gt;
        &lt;pages&gt;
      page1
        &lt;/pages&gt;
        &lt;/toc&gt;
         &lt;/toc1&gt;
      &lt;social&gt;
  &lt;/historical&gt;
  </code></pre>
  
  <p></p>
  
  <p>actually i am getting confused here </p>
  
  <pre><code> &lt;lesson&gt;
  chapter1 unit 1 page1
  &lt;/lesson&gt;
  &lt;lesson&gt;
   unit 1 
  &lt;/lesson&gt;
  </code></pre>
  
  <p>here i need two outpus </p>
  
  <p>for the first lesson i need it as above output</p>
  
  <p>for the second lesson i need it as output like below</p>
  
  <pre><code> &lt;historical&gt;
      &lt;social&gt;
         &lt;toc1&gt;
    &lt;toc&gt;
        &lt;unit&gt;
      unit 1
        &lt;/unit&gt;   
    &lt;toc&gt;
         &lt;/toc1&gt;
      &lt;social&gt;
  &lt;/historical&gt;
  </code></pre>
  
  <p>but sometimes i will get both type in xml i am totally confused how to do this.</p>
  
  <p>can any one guide me here it can be in both XSLT1.0 and XSLT2.0</p>
  
  <p>Regards
  Karthic</p>