[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: XML To CSV

Subject: Re: XML To CSV
From: "Bryce K. Nielsen" <bryce@xxxxxxxxxxx>
Date: Thu, 29 Jul 2004 02:44:06 -0600
xsl xml to csv
Andrew,

It's your xsl:for-each loop that is causing it to grab only the direct
children of Account, and not the children of the children. Probably would be
better to just make a massive, recursive template.

And, since XML-to-CSV falls in the realm of xmlLinguist, I'm also going to
suggest taking a look that product at http://www.xmllinguist.com . Mainly
depends on your production environments (i.e. will this be run on Windows or
not), xmlLinguist would solve your problem in a snap. It's a simple-to-use,
bi-directional Text-to-XML translator that supports hierarchical structures,
such as the Name nested beneath Account. Download the trial, see if it's a
match or not for you.

HTH,

Bryce K. Nielsen
SysOnyx, Inc. (www.sysonyx.com)
Makers of xmlLinguist, the Text-to-XML Translator
http://www.sysonyx.com/products/xmllinguist



----- Original Message ----- 
From: <ashushujev@xxxxxxxxxxxx>
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Thursday, July 29, 2004 2:08 AM
Subject:  XML To CSV


>
> Hi,
>
> I have an XML stream that I would like to convert to CSV file thru XSL
> transformation. I use the following stylesheet, but the problem is it
> only selects top elements within an 'Account' node and does not process
> elements for 'Name' element.
>
> Stylesheet:
> <?xml version="1.0"?>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> version="1.0">
> <xsl:output method="text"/>
> <xsl:template match="/">
> <xsl:apply-templates select="//Account[1]"/>
> </xsl:template>
> <xsl:template match="Account">
> <xsl:for-each select="*"><xsl:value-of select="."/><xsl:if test="last()
> > position()">,</xsl:if></xsl:for-each><xsl:text></xsl:text>
> </xsl:template>
> </xsl:stylesheet>
>
>
> XML:
> <?xml version="1.0"?>
> <Data>
>   <Account>
>     <AccountNumber>1000748</AccountNumber>
>     <SequenceNo>1</SequenceNo>
>     <AccountBalance>1052.35</AccountBalance>
>     <Name>
>       <CitizenNameTitle>Mr</CitizenNameTitle>
>       <CitizenNameForename>Joe</CitizenNameForename>
>       <CitizenNameSurname>Bloggs</CitizenNameSurname>
>     </Name>
>   </Account>
> </Data>
>
> Output:
> 1000748,1,1052.35,MrJoeBloggs
>
> I would appreciate any help in this matter.
>
> Andrew

Current Thread
  • XML To CSV
    • ashushujev - Thu, 29 Jul 2004 10:08:01 +0200
      • Bryce K. Nielsen - Thu, 29 Jul 2004 02:44:06 -0600 <=

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.