title: xsl to convert xml to json
body: <p>Input XML</p>
  
  <pre><code>&lt;Root&gt;
      &lt;Result&gt;
          &lt;System&gt;
              &lt;Name&gt;ABC&lt;/Name&gt;
              &lt;ID pname="PAD"&gt;
                  &lt;value&gt;4567&lt;/value&gt;
              &lt;/ID&gt;
              &lt;lastTime&gt;2013-11-06T17:36:46.000-05:00&lt;/lastTime&gt;
          &lt;/System&gt;
          &lt;line&gt;Metals&lt;/line&gt;
      &lt;/Result&gt;
      &lt;Result&gt;
          &lt;System&gt;
              &lt;Name&gt;CAYS&lt;/Name&gt;
              &lt;ID pname="PAD"&gt;
                  &lt;value&gt;MCIERT&lt;/value&gt;
              &lt;/ID&gt;
              &lt;ID pname="ATPAD"&gt;
                  &lt;value&gt;56412&lt;/value&gt;
              &lt;/ID&gt;
              &lt;lastTime&gt;2013-12-06T16:43:36.000-05:00&lt;/lastTime&gt;
          &lt;/System&gt;
          &lt;System&gt;
              &lt;Name&gt;CAYS&lt;/Name&gt;
              &lt;ID pname="CAD"&gt;
                  &lt;value&gt;DGSG&lt;/value&gt;
              &lt;/ID&gt;
              &lt;ID pname="ARCAD"&gt;
                  &lt;value&gt;2847114&lt;/value&gt;
              &lt;/ID&gt;
              &lt;lastTime&gt;2013-12-07T20:02:38.000-05:00&lt;/lastTime&gt;
          &lt;/System&gt;
          &lt;line&gt;Minerals&lt;/line&gt;
      &lt;/Result&gt;
  &lt;/Root&gt;
  </code></pre>
  
  <p>Output Json</p>
  
  <pre><code>{
  "Root": {
  "Result": [
    {
      "System": {
        "Name": "ABC",
        "ID": {
          "pname": "PAD",
          "value": "4567"
        },
        "lastTime": "2013-11-06T17:36:46.000-05:00"
      },
      "line": "Metals"
    },
    {
      "System": [
        {
          "Name": "CAYS",
          "ID": [
            {
              "pname": "PAD",
              "value": "MCIERT"
            },
            {
              "pname": "ATPAD",
              "value": "56412"
            }
          ],
          "lastTime": "2013-12-06T16:43:36.000-05:00"
        },
        {
          "Name": "CAYS",
          "ID": [
            {
              "pname": "CAD",
              "value": "DGSG"
            },
            {
              "pname": "ARCAD",
              "value": "2847114"
            }
          ],
          "lastTime": "2013-12-07T20:02:38.000-05:00"
        }
      ],
      "line": "Minerals"
    }
  ]
  }
  }
  </code></pre>
  
  <p>How to write the generic xslt stylesheet which will  convert input xml to json</p>
  
  <p>Input might have so many Results under root, Systems and Names under results and also ID name and the values under  systems.</p>