RE: [xsl] Converting XML source to CSV output

Subject: RE: [xsl] Converting XML source to CSV output
From: "Chris Pearson" <chrisp@xxxxxxxxxxx>
Date: Thu, 20 Sep 2001 12:24:41 -0400
THANK YOU All!  Your suggestions helped me get exactly what I was
looking for.
If anyone is curious, here's what I ended up using...

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:output method="text" media-type="text/plain" />
<xsl:strip-space elements="*"/>
<xsl:template match="//DETAIL">
   <xsl:variable name="detail" select="*/@value"/>
   <xsl:variable name="body" select="parent::BODY/*/@value"/>
   <xsl:variable name="header"
select="parent::BODY/preceding-sibling::HEADER[1]/*/@value"/>
   <xsl:variable name="all-elements" select="$header | $body |
$detail"/>
   <xsl:for-each select="$all-elements[position() != last()]">
      <xsl:value-of select="concat(.,',')"/>
   </xsl:for-each>
   <xsl:value-of select="concat($detail[last()], '&#xa;')"/>
</xsl:template>
</xsl:stylesheet>

Once again, a big thank you to all!

Chris

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread