XML to CSV Problem

R

rosemm

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?
 
M

Martin Honnen

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

=?ISO-8859-1?Q?J=FCrgen_Kahrs?=

rosemm said:
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 ?
 
A

Andy Dingley

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.
 

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,999
Messages
2,570,243
Members
46,836
Latest member
login dogas

Latest Threads

Top