|
Subject: Re: [xsl] Retrieving Full XPATH expression From: "john smith" <john_smith73@xxxxxxxxxxx> Date: Fri, 10 Aug 2001 19:09:41 +0000 |
<!--
Gets the full xpath of the current node.
For first index, [1] is not outputted
-->
<xsl:template match="*" mode="fullXPath" >
<xsl:for-each select="ancestor-or-self::*">
<xsl:variable name="id"
select="generate-id(.)" />
<xsl:variable name="name" select="name()" />
<xsl:value-of select="concat('/',name())"/>
<xsl:for-each select="../*[name()=$name]" >
<xsl:if test="generate-id(.)=$id and position() != 1">
<xsl:text>[</xsl:text>
<xsl:value-of
select="format-number(position(),'0')"/>
<xsl:text>]</xsl:text>
</xsl:if>
</xsl:for-each>
</xsl:for-each>
<xsl:if test="not(self::*)">
<xsl:value-of select="concat('/@',name())" />
</xsl:if>
</xsl:template>From: "john smith" <john_smith73@xxxxxxxxxxx> Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: [xsl] Retrieving Full XPATH expression Date: Fri, 10 Aug 2001 18:17:23 +0000
Given:
<A> <B> <C> <D id="007"> <E>val1</E> </D> <D id="008"> <E>val2</E> </D> <C> </B> </A>
How do I get the full Xpath for each node..For example, if the
context node is <E> (with value "val1"), I want to get its full xpath
as A/B/C/D[1]/E[1] and for the second occurrence of <E> (with value "val2"),
I want to get its full xpath as A/B/C/D[2]/E[2].
Thanks a lot for the help.
_________________________________________________________________ Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
_________________________________________________________________ Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| RE: [xsl] Retrieving Full XPATH exp, Tom Landon | Thread | [xsl] Why doesn't <xsl:for-each sel, Hewko, Doug |
| RE: [xsl] Retrieving Full XPATH exp, Tom Landon | Date | Re: [xsl] Calculate mantissa and ex, David_Marston |
| Month |