[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: 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
|
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
|