472,146 Members | 1,356 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,146 software developers and data experts.

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 3359
2,057 Expert 2GB
<xsl:variable name="xpath" select="name()"/>
<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
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

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.