Delimeting the output for xslt (in non trivial cases)

mentorgh

New Member
I would like to know the best way to delimit xml output in an xsl transform. "position() != last()" doesn't always work because it makes assumptions about the input.This toy example demonstrates:\[code\] <xsl:template match="/"> <html> <body> <xsl:for-each select="//cd"> <xsl:if test="title !='Unchain my heart'"> <xsl:value-of select="title" /> <xsl:if test="position() != last()"> <xsl:text>; </xsl:text> <!-- sometimes the delimiter will end if last element is a duplicate; --> </xsl:if> </xsl:if> </xsl:for-each> </body> </html> </xsl:template>\[/code\]will result in\[code\]... Pavarotti Gala Concert; The dock of the bay; Picture book; Red; \[/code\]note the trailing semicolon.Any ideas?(xml data from this example http://www.w3schools.com/xsl/tryxslt.asp?xmlfile=cdcatalog&xsltfile=cdcatalog)
 
Back
Top