469,613 Members | 1,952 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,613 developers. It's quick & easy.

Find Xpath Expn of current node using ancestor-or-self

I'm trying to Xpath EXprn for a current node(name unknown).I tried using the below syntax,but it fails .Pls help.



<xsl:variable name= "xpath" select ="name(ancestor-or-self::(.))"/>
Oct 5 '07 #1
4 3276
jkmyoung
2,057 Expert 2GB
probably
<xsl:variable name="xpath" select="name()"/>
or
<xsl:variable name="xpath" select="local-name()"/>
Oct 5 '07 #2
nmae() or local-name() would only return me th ename of the current node.But i'm trying to find out the Xpath Expression ,which would return the ancestors names also

I need the name of current node plus its ancestors.

ex: root/toplevelnode1/node2/ current node

So i tried :

<xsl:variable name= "xpath" select ="name(ancestor-or-self::[name()])"/>

I need the syntax which would return current nodes path from the root.Pls help.

thanks in advance.
Oct 5 '07 #3
jkmyoung
2,057 Expert 2GB
Expand|Select|Wrap|Line Numbers
  1. <xsl:variable name= "xpath">
  2.   <xsl:for-each select="ancestor::*">
  3.     <xsl:value-of select="name()"/><xsl:text>/</xsl:text>
  4.   </xsl:for-each>
  5.   <xsl:value-of select="name()"/>
  6. </xsl:variable>
Oct 5 '07 #4
Cool!! That worked Thanks!!
Oct 5 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

9 posts views Thread by Jon Thackray | last post: by
1 post views Thread by Colin Fox | last post: by
2 posts views Thread by Raed Sawalha | last post: by
13 posts views Thread by David Thielen | last post: by
2 posts views Thread by werD | last post: by
3 posts views Thread by Jason Mobarak | last post: by
reply views Thread by bruce | last post: by
reply views Thread by devrayhaan | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.