XML to CSV Problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • rosemm

    XML to CSV Problem

    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_D ATE/@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?

  • Martin Honnen

    #2
    Re: XML to CSV Problem



    rosemm wrote:

    [color=blue]
    > 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_D ATE/@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?[/color]

    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

    Comment

    • Jürgen Kahrs

      #3
      Re: XML to CSV Problem

      rosemm wrote:
      [color=blue]
      > 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[/color]

      For such simple conversions XSLT is overkill.
      [color=blue]
      > 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?[/color]

      Is XSLT a *must* or are you free to choose a
      more suitable tool ?

      Comment

      • Andy Dingley

        #4
        Re: XML to CSV Problem

        On Thu, 20 Jan 2005 20:38:37 +0100, Jürgen Kahrs
        <Juergen.KahrsD ELETETHIS@vr-web.de> wrote:
        [color=blue]
        >For such simple conversions XSLT is overkill.[/color]

        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

        Comment

        Working...