Subject: Re: [xsl] Transforming XML to CSV From: Abel Braaksma <abel.online@xxxxxxxxx> Date: Thu, 10 Jan 2008 12:33:45 +0100 |
Folks
Firstly apologies if this a no-brainer, I am an XSL beginner.
We have an XML output file that we need to convert into CSV for some customers.
Can this be done with a Transform?
Are there any good examples of how one might approach it?
<xsl:template match="/"> <!-- starting point for root node --> <!-- put your header line for the CSV here --> <xsl:apply-templates select="my-names/row" /> </
<xsl:template match="row"> <xsl:apply-templates select="field" /> <!-- newline at end of each row --> <xsl:text>
</xsl:text> </
<xsl:template match="field"> <!-- each field --> <xsl:value-of select="." />
<!-- only output comma separator if not at last field --> <xsl:if test="position() != last()"> <xsl:text>,</xsl:text> </xsl:if> </
<my-names> <row> <field>Abel</field> <field>Braaksma</field> </row> <row> <field>John</field> <field>Doe</field> </row> </my-names>
Abel,Braaksma John,Doe
Cheers, -- Abel Braaksma
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Transforming XML to CSV, Eric Bréchemier | Thread | Re: [xsl] Transforming XML to CSV, Jesper Tverskov |
Re: [xsl] Transforming XML to CSV, Eric Bréchemier | Date | [xsl] Re: [FO] Background image on , Vincent Hennebert |
Month |