Subject: Re: [xsl] XSTL - Help / Easy one! From: Mike Brown <mike@xxxxxxxx> Date: Tue, 5 Feb 2002 19:56:04 -0700 (MST) |
Ragan, Mitch wrote: > How can I remove the "trailing coma" on this XSLT output > with our using an "if" statement: > > XSLT: > <xsl:template match="Portfolio/Stock"> > <xsl:apply-templates select="Symbol"/>, > </xsl:template> You're going to get 9 zillion answers, all variations of: <xsl:template match="Portfolio/Stock"> <xsl:apply-templates select="Symbol"/> <xsl:if test="position() != last()">,</xsl:if> </xsl:template> But they'll probably neglect to mention that you should do it like this <xsl:template match="/"> <xsl:apply-templates select="Portfolio/Stock"/> </xsl:template> <xsl:template match="Stock"> <xsl:apply-templates select="Symbol"/> <xsl:if test="position() != last()">,</xsl:if> </xsl:template> so you can ensure that position() and last() work as expected, returning numbers that are relative to the set of Stock elements that have been selected for processing, rather than the set of all children of the parent element or root node, as the built-in templates would otherwise cause to be processed. - Mike ____________________________________________________________________________ mike j. brown, fourthought.com | xml/xslt: http://skew.org/xml/ denver/boulder, colorado, usa | personal: http://hyperreal.org/~mike/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] XSTL - Help / Easy one!, Ragan, Mitch | Thread | RE: [xsl] XSTL - Help / Easy one!, Michael Kay |
[xsl] XSL output problem, Arief | Date | [no subject], anjali chipalkatti |
Month |