Subject: RE: [xsl] Unique local-name() From: "Dion Houston" <dionh@xxxxxxxxxxxxxxxxxxxxx> Date: Sat, 22 Feb 2003 21:10:12 -0800 |
Hi Niklas: I don't think you'll find any context free, Xpath only method of doing this. Reason why is because the current() function always takes you out to the current node. For an XSLT solution, here's what I recommend: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:key match="/root/*" use="local-name()" name="local-name"/> <xsl:template match="root"> <xsl:copy-of select="*[not(key('local-name',local-name())[2])]"/> </xsl:template> </xsl:stylesheet> This is simply does a key on the local name of all children of root, and copies a node if there is no second node with the same name. If you want to do any more processing on the node, simply apply-templates instead of copy-of. HTH! Dion -----Original Message----- From: Niklas Gustavsson [mailto:niklas@xxxxxxxxxxxxx] Sent: Saturday, February 22, 2003 6:29 PM To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx Hi all, I'm really stuck on a XPpath problem that should be fairly simple (I think): I need to check if an element that got a unique local-name() among it's siblings. And, I have no way of actually knowing the local-name() when I generate the XPath. For example: <root> <a /> <b /> <b /> <c /> <c /> <d /> </root> a and d should pass, the b's and c's shouldn't If my question isn't clear enough I try to clarify my problem some more :-) Thanks! /niklas XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Unique local-name(), Michael Kay | Thread | [xsl] Import stylesheets in Xalan a, Andrey Guskov |
[xsl] Unique local-name(), Niklas Gustavsson | Date | [xsl] Import stylesheets in Xalan a, Andrey Guskov |
Month |