XML to CSV made easy?

A

Alex

Hi everyone. My problem is essentially financial. Here it is:

I need to create XSLT to transform XML data into CSV (and back again,
but that's for another day). I have created XSLTs in the past, but it
is a painful, time-consuming experience. It would be nice if there was
a tool in whice I could basically say: here is my XML, here is what I
want to transform the data to. Please generate the XSL for me.

Now on to finances: I must use something that's free. So does anyone
know of a free utility that can do this?
 
R

Ray Tayek

Alex said:
Hi everyone. My problem is essentially financial. Here it is:

I need to create XSLT to transform XML data into CSV ...

i just did somethign like this except it went csv->xml>->xml->csv.
generating the csv is pretty straigtforward (see below) (just google for
xslt and csv).

for the csvparser, i used ostermillerutils_1_02_21.jar from
http://ostermiller.org/ as it claims to eat both standard csv and excel csv.

hth

<?xml version="1.0" encoding="UTF-8"?>
<?xmlspysamplexml
U:\projects\tender\tender2\com\ediidea\tender\testFiles\martinsExcelSample1Out.xml?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:eek:utput method="text"/>
<xsl:strip-space elements="*"/>
<xsl:param name="name1"/>
<!-- not used, but may ne usefule later -->
<xsl:template match="outputDocument/header">
<xsl:apply-templates select="*">
<xsl:sort select="@icn"/>
</xsl:apply-templates>
<!--xsl:text>
</xsl:text-->
</xsl:template>
<xsl:template match="outputDocument/header/*">
<!--
<xsl:value-of select="."/>
<xsl:if test="position() != last()">,</xsl:if>
-->
</xsl:template>
<xsl:template match="outputDocument/csvHeader">
<xsl:value-of select="."/>
<xsl:text>
</xsl:text>
</xsl:template>
<xsl:template match="outputDocument/row">
<xsl:apply-templates/>
<xsl:text>
</xsl:text>
</xsl:template>
<xsl:template match="outputDocument/row/*">
<xsl:value-of select="."/>
<xsl:if test="position() != last()">,</xsl:if>
</xsl:template>
</xsl:stylesheet>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top