I am new to XSL and am trying to create a text csv header row with the code below. All I get is the content of each StartTime tag. What am I missing?
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
<xsl:output method="text" omit-xml-declaration="yes" encoding="UTF-8" indent="no" />
<xsl:variable name="headers">
<xsl:call-template name="do_header">
<xsl:with-param name="headers" select="//Event//@channel[not(.=../../preceding-sibling::Event//@channel)]" />
</xsl:call-template>
</xsl:variable>
<!-- Write the Header -->
<xsl:template name="do_header">
<xsl:param name="headers" />
<xsl:text>Time,</xsl:text>
<xsl:for-each select="$headers">
<xsl:value-of select="."/>
<xsl:text>,</xsl:text>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Example XML:
<?xml version="1.0" encoding="UTF-8"?>
<Program>
<Event>
<StartTime units="us">5</StartTime>
<LaserOn channel="HeNe Laser" />
</Event>
<Event>
<StartTime units="us">15</StartTime>
<LaserOff channel="HeNe Laser" />
</Event>
<Event>
<StartTime units="us">55</StartTime>
<LaserOn channel="HeNe Laser" />
<LaserOn channel="TiSaph" />
</Event>
<Event>
<StartTime units="us">125</StartTime>
<LaserOff channel="TiSaph" />
</Event>
<Event>
<StartTime units="us">905</StartTime>
<LaserOn channel="HeNe Laser" />
<LaserOn channel="TiSaph" />
</Event>
<Event>
<StartTime units="us">1500</StartTime>
<LaserOff channel="HeNe Laser" />
</Event>
</Program>
Output of the xslt. It only output the content of the StartTime tags ie. 5 15 55 125 905 1500