Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - question >Thread Next - Re: question Re: questionTo: NULL Date: 1/4/2005 8:28:00 PM Hi, > I'm trying to capture elements from an XML document by using an XSL document that splits the XML elements with a comma. When I apply my XSL with the XML, it gives all of the elements followed by a comma, but the last element has a comma attached to it also. I don't want that last comma. What can I do to get rid of the comma that is attached to the last element. One solution is to strip of the last delimiter with XPath: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output omit-xml-declaration="yes"/> <xsl:template match="/eBay/*"/> <xsl:template match="/eBay/WatchList"> <xsl:variable name="out"> <xsl:apply-templates select="Items/Item/Id"/> </xsl:variable> <xsl:value-of select="substring($out,1,string-length($out)-1)"/> </xsl:template> <xsl:template match="Id"> <xsl:value-of select="."/><xsl:text>,</xsl:text> </xsl:template> </xsl:stylesheet> Another option is preventing the delimiter from being added the last time. SOmething like this: <xsl:template match="/eBay/WatchList"> <xsl:apply-templates select="Items/Item/Id"/> </xsl:template> <xsl:template match="Id[count(following::Id)!=0]"> <xsl:value-of select="."/><xsl:text>,</xsl:text> </xsl:template> regards, -- Joris Gillis (http://www.ticalc.org/cgi-bin/acct-view.cgi?userid=38041) Spread the wiki (http://www.wikipedia.org) | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
