title: Transform one XML format to another XML format using XSL
body: <p>I have a code with XML output as</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="windows-1252" standalone="yes"?&gt;
  &lt;products&gt;
      &lt;product&gt;
          &lt;name&gt;abc&lt;/name&gt;
          &lt;id&gt;1&lt;/id&gt;
      &lt;/product&gt;
      &lt;product&gt;
          &lt;name&gt;klm&lt;/name&gt;
          &lt;id&gt;2&lt;/id&gt;
      &lt;/product&gt;
  &lt;/products&gt;
  </code></pre>
  
  <p>I want the same XML to be displayed in following format as well:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="windows-1252" standalone="yes"?&gt;
  &lt;products&gt;
      &lt;product&gt;
          &lt;name&gt;
              &lt;value&gt;abc&lt;/value&gt;
              &lt;unit&gt;&lt;/unit&gt;
          &lt;/name&gt;
          &lt;id&gt;
              &lt;value&gt;1&lt;/value&gt;
              &lt;unit&gt;&lt;/unit&gt;
          &lt;/id&gt;
          &lt;product&gt;
          &lt;name&gt;
              &lt;value&gt;klm&lt;/value&gt;
              &lt;unit&gt;&lt;/unit&gt;
          &lt;/name&gt;
          &lt;id&gt;
              &lt;value&gt;2&lt;/value&gt;
              &lt;unit&gt;&lt;/unit&gt;
          &lt;/id&gt;
  &lt;/product&gt;
  </code></pre>
  
  <p>How can i do it using XSLT?</p>
  
  <p>I am using Spring environment. XML tags for product are variable. These vary by kind of products. The code to generate XML is</p>
  
  <pre><code>JAXBContext jc;
  try {
     jc = JAXBContext.newInstance(cla);
     Marshaller m;
     m = jc.createMarshaller();
     m.marshal(obj, out); 
  } catch (JAXBException e) {
     e.printStackTrace();
  }
  </code></pre>
  
  <p>Edit:
  product may have weight attribue, so there will also be a tag of </p>
  
  <pre><code>&lt;weight&gt;10lbs&lt;weight&gt;
  </code></pre>
  
  <p>This tage will break into </p>
  
  <pre><code>&lt;weight&gt;
      &lt;value&gt;10&lt;/value&gt;
      &lt;unit&gt;lbs&lt;/unit&gt;
  &lt;/weight&gt; 
  </code></pre>