This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: Converting XML source to CSV output


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]