title: xslt to convert to json
body: <p>INPUT I'm getting: </p>
  
  <pre><code>  &lt;table&gt;   
      &lt;source1&gt;
        &lt;ptr&gt;
            &lt;data name="text1"&gt;20431&lt;/data&gt;
            &lt;data name="text2"&gt;collins&lt;/data&gt;
            &lt;data name="text3"&gt;20141231&gt;&lt;/data&gt;
            &lt;data name="text4"&gt;regard&lt;/data&gt;
        &lt;/ptr&gt;
      &lt;/source1&gt;
      &lt;source2&gt;
          &lt;ptr&gt;
              &lt;data name="note1"&gt;C&lt;/data&gt;
              &lt;data name="note2"&gt;A&lt;/data&gt;
              &lt;data name="note3"&gt;22356&lt;/data&gt;
              &lt;data name="note4"&gt;465506&lt;/data&gt;
              &lt;data name="note5"&gt;434562491057912&lt;/data&gt;
              &lt;data name="note6"&gt;milk&lt;/data&gt;
              &lt;data name="note7"&gt;dfRTA&lt;/data&gt;
          &lt;/ptr&gt;
      &lt;/source2&gt;
      &lt;source3&gt;
      &lt;enroll&gt;n&lt;/enroll&gt;
      &lt;/source3&gt;
      &lt;/table&gt;
  </code></pre>
  
  <p>need to convert this to json as</p>
  
  <pre><code>{
  "table":
  {
  "source1":
  {"text1":"20431",
  "text2": "collins",
  "text3": "20141231",
  "text4" :"regard"
  },
  "source2":
  {"note1":"20431",
  "note2": "A",
  "note3":"22356",
  "note4":"465506",
  "note5":"434562491057912",
  "note6":"milk",
  "note7":"dfRTA"
  }
  }}
  </code></pre>
  
  <p>How to convert using xsl any generic one instead of matching on each attribute name.
  Any one has the stylesheet which will do the above transformation</p>