Mega Code Archive

 
Categories / XML / XSLT StyleSheet
 

Output a comma if its not the last one in the node

File: Data.xml <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"   version="1.0">   <xsl:output method="xml" omit-xml-declaration="yes" indent="no" />   <xsl:template match="figure/title">     <xsl:apply-templates />   </xsl:template>   <xsl:template match="para" /> </xsl:stylesheet> File: Transform.xslt <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"   version="1.0">   <xsl:output method="xml" omit-xml-declaration="yes" />   <xsl:template match="title">     <xsl:text>title ancestors:</xsl:text>     <xsl:for-each select="ancestor::*">       <xsl:value-of select="name()" />       <xsl:if test="position() != last()">         <xsl:text>,</xsl:text>       </xsl:if>     </xsl:for-each>   </xsl:template>   <xsl:template match="para" />    </xsl:stylesheet>