[Home] [By Thread] [By Date] [Recent Entries]
i have added a root element( assets ) to ur xml elements and started
working..
here is it <assets> <asset>Oil</asset> <asset>Oil</asset> <asset>Diamonds</asset> <asset>Diamonds</asset> </assets> for this the xsl that would give u unique elements.. <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output omit-xml-declaration="yes"/> <xsl:template match="/"> <xsl:apply-templates select="assets/asset"/> </xsl:template> <xsl:template match="asset"> <xsl:if test="not(. = preceding-sibling::asset)"> <xsl:value-of select="."/>. </xsl:if> </xsl:template> </xsl:stylesheet> or a BETTER Approach is <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:key name="assets" match="asset" use="text()"/> <xsl:template match="assets"> <xsl:apply-templates select="asset[count( . | key('assets',.)[1]) =1]"/> </xsl:template> </xsl:stylesheet> -------------- From: "Craig Aranjo" <aranjo@xxxxxxxxxxxxxxxx> Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx To: <XSL-List@xxxxxxxxxxxxxxxxxxxxxx> Subject: Selecting uniquely one 'asset' in XSL Date: Thu, 25 Apr 2002 09:40:06 +0100 _________________________________________________________________ Join the world?s largest e-mail service with MSN Hotmail. http://www.hotmail.com XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|

Cart



