XML to CSV Problem

Discussion in 'XML' started by rosemm, Jan 20, 2005.

  1. rosemm

    rosemm Guest

    Hi,

    I am having a problem with a conversion program I am writing to change
    XML to a CSV. The biggest problem is I can't figure out how to get all
    the text for one record on a single line without having one really
    really long line of code like this:

    <xsl:value-of select="NAME/LAST/@VALUE"/>,<xsl:value-of
    select="NAME/FIRST/@VALUE"/>,<xsl:value-of
    select="NAME/MIDDLE//@VALUE"/>,<xsl:value-of
    select="CITY_OF_BIRTH/@VALUE"/>,<xsl:value-of
    select="BIRTH_DATE/@VALUE"/><xsl:text>
    </xsl:text>

    Yes that is just one line of code! The problem is that this is like
    1/10 of the data I have for every record plus I need to do
    manipulations on the data. Does anyone have any idea how I can have
    each separate piece of data on a different line and end up with all of
    one record on the same line?
    rosemm, Jan 20, 2005
    #1
    1. Advertising

  2. rosemm wrote:


    > I am having a problem with a conversion program I am writing to change
    > XML to a CSV. The biggest problem is I can't figure out how to get all
    > the text for one record on a single line without having one really
    > really long line of code like this:
    >
    > <xsl:value-of select="NAME/LAST/@VALUE"/>,<xsl:value-of
    > select="NAME/FIRST/@VALUE"/>,<xsl:value-of
    > select="NAME/MIDDLE//@VALUE"/>,<xsl:value-of
    > select="CITY_OF_BIRTH/@VALUE"/>,<xsl:value-of
    > select="BIRTH_DATE/@VALUE"/><xsl:text>
    </xsl:text>
    >
    > Yes that is just one line of code! The problem is that this is like
    > 1/10 of the data I have for every record plus I need to do
    > manipulations on the data. Does anyone have any idea how I can have
    > each separate piece of data on a different line and end up with all of
    > one record on the same line?


    Try to use <xsl:text> to have your literal text output e.g.
    <xsl:template match="/">
    <xsl:value-of select="NAME/LAST/@VALUE" />
    <xsl:text>,</xsl:text>
    <xsl:value-of select="NAME/FIRST/@VALUE" />
    <xsl:text>,</xsl:text>
    </xsl:template>


    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
    Martin Honnen, Jan 20, 2005
    #2
    1. Advertising

  3. rosemm wrote:

    > I am having a problem with a conversion program I am writing to change
    > XML to a CSV. The biggest problem is I can't figure out how to get all


    For such simple conversions XSLT is overkill.

    > manipulations on the data. Does anyone have any idea how I can have
    > each separate piece of data on a different line and end up with all of
    > one record on the same line?


    Is XSLT a *must* or are you free to choose a
    more suitable tool ?
    =?ISO-8859-1?Q?J=FCrgen_Kahrs?=, Jan 20, 2005
    #3
  4. rosemm

    Andy Dingley Guest

    On Thu, 20 Jan 2005 20:38:37 +0100, J├╝rgen Kahrs
    <> wrote:

    >For such simple conversions XSLT is overkill.


    If the convenient tool you have is Xalan/Xerces, then everything looks
    like an XSLT problem.

    I just wouldn't worry about the long "lines", or line-break things
    before the closing > of a tag if you have to. XSLT source code just
    is somewhat ugly for human-readability.
    --
    Smert' spamionam
    Andy Dingley, Jan 21, 2005
    #4
    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. Michal Mikolajczyk
    Replies:
    0
    Views:
    630
    Michal Mikolajczyk
    Feb 13, 2004
  2. Skip Montanaro
    Replies:
    0
    Views:
    695
    Skip Montanaro
    Feb 13, 2004
  3. Tintin92
    Replies:
    1
    Views:
    1,674
    Andrew Thompson
    Feb 14, 2007
  4. jliu66
    Replies:
    0
    Views:
    493
    jliu66
    Oct 19, 2007
  5. sso
    Replies:
    20
    Views:
    2,616
    Martin Gregorie
    Apr 26, 2009
Loading...

Share This Page