|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Unique local-name()
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
|
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
|

Cart








