OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help



   Re: [xml-dev] Converting xml to csv with xslt

[ Lists Home | Date Index | Thread Index ]

Jerry Lake wrote:

> I'm still working on my xslt. Can someone give me an example or point me
> in the right direction to convert my XML to CSV

It's a transformation problem.  You have to decide what the csv should 
look like, given the xml source.

Since you will be outputting text, you need to specify the text output 
method in your xslt stylesheet.  The other thing you have to do is to 
write a little template that will add a comma after each field except 
for the last one in a row, and another that will escape fields whose 
text contains a comma.  These tasks are typically done with small 
recursive templates.

If you need to group items together in a way that they are not grouped 
in the xml source, you may need to use one or another of the standard 
grouping techniques.  Just look in the various on-line FAQs and xslt 
sites for grouping techniques and for these kinds of recursive templates.

Dave Pawson's site, and Jeni Tennison's site, would be really good 
starting references.

Start hanging out on the Mulberry xsl list.

Don't worry, xslt has been used for generating Python, javascript, SQL, 
and a host of other text formats.  It will work fine for csv.


Tom P


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS