[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: XSTL - Help / Easy one!
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|