title: json to csv using xslt
body: <p>I'm new to the xslt.</p>
  <p>I'm trying to converting json to csv using xslt.</p>
  <p>Here is the input json</p>
  <pre><code>[
      {
          &quot;id&quot;: &quot;1&quot;,
          &quot;name&quot;: &quot;manu&quot;
      },
      {
          &quot;id&quot;: &quot;2&quot;,
          &quot;name&quot;: &quot;vivek&quot;
      }
  ]
  </code></pre>
  <p>and XSLT is:-</p>
  <p>I'm very sure I'm not doing the proper mapping in the select attribute.</p>
  <p>Can anyone please help me with this</p>
  <pre><code>&lt;xsl:stylesheet xmlns:xsl=&quot;http://www.w3.org/1999/XSL/Transform&quot; 
      extension-element-prefixes=&quot;math&quot;
      xmlns:math=&quot;http://exslt.org/math&quot; 
      xmlns:xs=&quot;http://www.w3.org/2001/XMLSchema&quot; version=&quot;3.0&quot; xmlns=&quot;http://www.w3.org/2005/xpath-functions&quot;  xpath-default-namespace=&quot;http://www.w3.org/2005/xpath-functions&quot; expand-text=&quot;yes&quot; &gt; 
      &lt;xsl:param name=&quot;input&quot;/&gt; 
      &lt;xsl:output method=&quot;text&quot;/&gt; 
      
      &lt;xsl:template match=&quot;/&quot;&gt;
      &lt;xsl:apply-templates/&gt;
      &lt;/xsl:template&gt;
  
  &lt;xsl:template name=&quot;initial-template&quot;&gt; 
  &lt;xsl:variable name=&quot;input-as-xml&quot; select=&quot;json-to-xml($input)&quot;/&gt; 
         
  &lt;xsl:for-each select=&quot;$input-as-xml//*&quot;&gt;
  
              
      &lt;xsl:variable name=&quot;eachData&quot; select=&quot;.&quot;&gt;&lt;/xsl:variable&gt;
      &lt;xsl:choose&gt;
          &lt;xsl:when test=&quot;contains($eachData,',')&quot;&gt;
              &lt;xsl:value-of select=&quot;replace($eachData, ',', ' ')&quot;/&gt;
          &lt;/xsl:when&gt;
          &lt;xsl:otherwise&gt;
              &lt;xsl:value-of select=&quot;$eachData&quot;/&gt;
          &lt;/xsl:otherwise&gt;
      &lt;/xsl:choose&gt;
      &lt;xsl:if test=&quot;position() != last()&quot;&gt;
          &lt;xsl:value-of select=&quot;','&quot;/&gt;
      &lt;/xsl:if&gt;
  
  &lt;/xsl:for-each&gt;
  &lt;xsl:text&gt;&amp;#10;&lt;/xsl:text&gt;
  &lt;/xsl:template&gt;           
  &lt;/xsl:stylesheet&gt;
  
  </code></pre>