Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > XML to CSV made easy?

Reply
Thread Tools

XML to CSV made easy?

 
 
Alex
Guest
Posts: n/a
 
      12-12-2003
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?
 
Reply With Quote
 
 
 
 
Ray Tayek
Guest
Posts: n/a
 
      12-13-2003
Alex wrote:
> 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\test Files\martinsExcelSample1Out.xml?>
<xsl:stylesheet version="1.0"
xmlnssl="http://www.w3.org/1999/XSL/Transform">
<xslutput method="text"/>
<xsl:strip-space elements="*"/>
<xslaram 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>

---
ray tayek http://tayek.com/ actively seeking mentoring or telecommuting work
vice chair orange county java users group http://www.ocjug.org/
hate spam? http://samspade.org/ssw/
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
read and write csv file using csv module jliu66 Python 0 10-19-2007 03:12 PM
How to move data from a CSV file to a JTable, and from a JTable to a CSV file ? Tintin92 Java 1 02-14-2007 06:51 PM
Rebel XT, made in Japan, made in Thailand jazu Digital Photography 10 12-12-2006 05:11 AM
Re: csv writerow creates double spaced excel csv files Skip Montanaro Python 0 02-13-2004 08:50 PM
csv writerow creates double spaced excel csv files Michal Mikolajczyk Python 0 02-13-2004 08:38 PM



Advertisments