This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: === Identifying a unique node in a DOM tree ===
- To: xsl-list at mulberrytech dot com
- Subject: Re: === Identifying a unique node in a DOM tree ===
- From: Francis Norton <francis at redrice dot com>
- Date: Tue, 30 May 2000 22:29:27 +0100
- References: <D79909C367EAD3118D3E00508B9B0EF5042EAF@NYC3MSG01>
- Reply-To: xsl-list at mulberrytech dot com
Jonathan Asbell wrote:
>
...
> I want to be able to ask the node.."who are you" and it would reply "I am
> currently /.people.person.name.John"
>
David did come up with the solution to this as a one-liner (which I
luckily saw before I could post my own particularly horrid and laborious
solution).
Just for completeness, I packaged his solution into two call-by-name
templates (for attributes and templates) which I've re-posted below only
because the xsl-list archive seems to be down right now.
Hope this helps -
Francis.
<!-- paths from elements -->
<xsl:template name="elementPath">
<xsl:for-each select="(ancestor-or-self::*)">/*[<xsl:value-of
select="1+count(preceding-sibling::*)"/>]</xsl:for-each>
</xsl:template>
<!-- paths from attributes -->
<xsl:template name="attributePath">
<xsl:for-each select="parent::*">
<xsl:call-template name="elementPath" />
</xsl:for-each>
<xsl:text>/@</xsl:text>
<xsl:value-of select="name(.)"/>
</xsl:template>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list