|
[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Converting xml to csv with xslt
Here is a link to my xml http://www.upstarter.com/xml/catalog.xml Thanks for the example. I am basically at square one, with all the proverbial irons in the fire. Cheers, J. -----Original Message----- From: G. Ken Holman [mailto:gkholman@C...] Sent: Wednesday, April 07, 2004 4:26 PM To: xml-dev@l... Subject: Re: Converting xml to csv with xslt At 2004-04-07 15:59 -0700, 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 You don't say where you are having problems so it is difficult to advise. A simple example is below ... it would need to be beefed up to accommodate escaping of characters following CSV conventions, but it should give you the flavour of what you need. You don't give an example of your data either, so I have no idea how applicable the structure is to your work. I hope this helps. .................... Ken T:\ftemp>type jerry.xml <records> <record> <field1>abc</field1><field2>def</field2> </record> <record> <field1>abc</field1><field2>def</field2> </record> <record> <field1>abc</field1><field2>def</field2> </record> <record> <field1>abc</field1><field2>def</field2> </record> </records> T:\ftemp>type jerry.xsl <?xml version="1.0" encoding="iso-8859-1"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="text"/> <xsl:template match="records"> <xsl:for-each select="record"> <xsl:apply-templates select="*"/> <xsl:text><!--new line at the end of the information--> </xsl:text> </xsl:for-each> </xsl:template> <xsl:template match="*"><!--put out element content in quotes--> <xsl:if test="position()>1">,</xsl:if><!--more than one being processed--> <xsl:text/>"<xsl:apply-templates/>"<xsl:text/> </xsl:template> </xsl:stylesheet> T:\ftemp>saxon jerry.xml jerry.xsl "abc","def" "abc","def" "abc","def" "abc","def" T:\ftemp> -- Public courses: Spring 2004 world tour of hands-on XSL instruction Each week: Monday-Wednesday: XSLT/XPath; Thursday-Friday: XSL-FO Hong Kong May 17-21; Bremen Germany May 24-28; Helsinki June 14-18 World-wide on-site corporate, govt. & user group XML/XSL training. G. Ken Holman mailto:gkholman@C... Crane Softwrights Ltd. http://www.CraneSoftwrights.com/x/ Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995) Male Breast Cancer Awareness http://www.CraneSoftwrights.com/x/bc ----------------------------------------------------------------- The xml-dev list is sponsored by XML.org <http://www.xml.org>, an initiative of OASIS <http://www.oasis-open.org> The list archives are at http://lists.xml.org/archives/xml-dev/ To subscribe or unsubscribe from this list use the subscription manager: <http://www.oasis-open.org/mlmanage/index.php>
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|
|||||||||

Cart








