XML to CSV made easy?

Discussion in 'XML' started by Alex, Dec 12, 2003.

  1. Alex

    Alex Guest

    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?
     
    Alex, Dec 12, 2003
    #1
    1. Advertising

  2. Alex

    Ray Tayek Guest

    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\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>

    ---
    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/
     
    Ray Tayek, Dec 13, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mel
    Replies:
    0
    Views:
    370
  2. Robert Buck
    Replies:
    0
    Views:
    455
    Robert Buck
    Feb 24, 2004
  3. Replies:
    0
    Views:
    347
  4. MSDN Search made easy

    , Dec 7, 2007, in forum: ASP .Net
    Replies:
    1
    Views:
    301
    Peter Bromberg [C# MVP]
    Dec 7, 2007
  5. rzt8lias

    Christmas Shopping Made Easy

    rzt8lias, Dec 13, 2007, in forum: Python
    Replies:
    0
    Views:
    303
    rzt8lias
    Dec 13, 2007
Loading...

Share This Page