XSL Transform XML to CSV

Published Tue, Apr 13 2004 23:00 | coad

“VocabularyToCSV.xsl”

 

Since Comma Separated Value (CSV) files are so common, here is a transformation.  It requires “Vocabulary.xml” and a translator.

 

 

<?xml version="1.0"?>

 

<!-- Created by Noah Coad, coad.net/noah, noah@coad.net, 3/23/04 -->

 

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

   <xsl:output method="text" encoding="ISO-8859-1"/>

   <xsl:strip-space elements="Set"/>

   <xsl:template match="/Vocabulary">Word,Description

<xsl:apply-templates select="Set">

         <xsl:sort select="Word"/>

      </xsl:apply-templates>

   </xsl:template>

 

   <xsl:template match="Set">

      <xsl:value-of select="Word"/>,"<xsl:value-of select="Desc"/>"<xsl:text>&#13;&#10;</xsl:text>

   </xsl:template>

</xsl:stylesheet>

 

 

Filed under: