This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: converting XML to comma-separated value text file


> I've been surfing the web for a couple hours, but can't find a basic
> discussion of how to convert XML to a CSV text file.
> (My background:  I have modified pre-existing XSL stylesheets to convert
> the following type of XML into HTML.)  Thanks!

If you want general advice, put an <xsl:output method="text"/> element at
the beginning of your stylesheet so that characters like < and & don't get
escaped, and then output your attribute values with <xsl:value-of
select="@attributeName"/> (each followed by a comma) and your element text
content with either a similar xsl:value-of element (without the @, of
course) or or by using the default XSLT template rules, which output element
content. (In the latter case, put your commas after the appropriate
xsl:apply-templates elements.) You may need some xsl:text elements here and
there to control the appearance of carriage returns.

There's a brief example in my book of creating CSV files in my book.

If you want more specific advice, you'll have to show us what you tried and
what went wrong.

Bob DuCharme            www.snee.com/bob             <bob@
snee.com>      see http://www.snee.com/bob/xsltquickly for
info on new book "XSLT Quickly" from Manning Publications.



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]