Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: question

From: "Joris Gillis" <roac@-------.-->
To: 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)


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent