You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Marco Flores <ma...@dextratech.com> on 2000/11/10 23:34:51 UTC

A Doubt

Excuse me but i need to convert an XML file to CSV file, would you please me guide me with this issue? I do not know very well the Xalan-C++ API but I am working on it. The proble is that I don't uderstand too much the XML and XSL concepts...    
Thanks and Best Regards


Marco

RE: A Doubt

Posted by Tim Burns <tb...@owlmountain.com>.
Hi Marco,

I would start with something like this.  Say you have an XML file.  Note
that the --X-- and --/X-- are simply begin and end delimiters that are not
the actual contents of the file.  I haven't actually tested these, so that
would be an exercise for the reader.  ;)   For an excellent reference, run,
don't walk, down to your local independant bookseller and put in an order
for the "XSLT Programmer's Reference" by Michael Kay.

Best,
Tim

--XML--
<a>
    <b>Hello</b>
    <c>World</c>
    <d>Foo</d>
    <e>Bar</e>
</a>
---/XML--

The logical CSV file for this XML object is as follows:

--CSV named "a"--
b,c,d,e
Hello,World,Foo,Bar
--/CSV--

To translate this file you would apply the XML template to it.

--XSLT--
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
b,c,d,e
<xsl:apply-templates select="a"/>

<xsl:template match="a">
<xsl:value-of select="b"/>,<xsl:value-of select="c"/>,<xsl:value-of
select="d"/>,<xsl:value-of select="e"/>
</xsl:template>
</xsl:stylesheet>
--/XSLT--


Tim Burns
Owl Mountain Software, LLC
http://www.owlmountain.com

  -----Original Message-----
  From: Marco Flores [mailto:maflores@dextratech.com]
  Sent: Friday, November 10, 2000 4:35 PM
  To: xalan-dev@xml.apache.org
  Subject: A Doubt


  Excuse me but i need to convert an XML file to CSV file, would you please
me guide me with this issue? I do not know very well the Xalan-C++ API but I
am working on it. The proble is that I don't uderstand too much the XML and
XSL concepts...
  Thanks and Best Regards


  Marco