• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Confused with Xpath expression! Need Help.

 
Vivek Saxena
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Following question is from "Test 3 " of XMLWhiz. I am having problem to
under stand the Xpath expression.

What is the difference between
"//a[(following::x)]"
&
"//a[(following::x=.)]"

I know with "//a[(following::x)]" we will get all "a" elements which has "x" as following element.
I have no idea about the expression
"//a[(following::x=.)]".
Please help me !

Thanks
[ March 10, 2003: Message edited by: Vivek Saxena ]
 
Vivek Saxena
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any help would great!
Waiting.
Thanks
 
Raj Yelnare
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When I did use the stylesheet as
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:element name='Root'>
<xsl:call-template name="v3"/>
</xsl:element></xsl:template>
<xsl:template name="v3">
<xsl:variable name="v3List" select="//a[not(following::x=.)] | //x[not(preceding::a=.)] "/>
<xsl:for-each select="$v3List"><a><xsl:value-of select="."/>
</a></xsl:for-each>
</xsl:template>
</xsl:stylesheet>
The browser gave me
3432354
When I included the stylesheet as
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:element name='Root'>
<xsl:call-template name="v3"/>
</xsl:element></xsl:template>
<xsl:template name="v3">
<xsl:variable name="v3List" select="//a[not(following::x)] | //x[not(preceding::a=.)] "/>
<xsl:for-each select="$v3List"><a><xsl:value-of select="."/>
</a></xsl:for-each>
</xsl:template>
</xsl:stylesheet>
The browser gave me
3454
 
Vivek Saxena
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is what i don't understand. There is a difference between "//a[(following::x)]" &
"//a[(following::x=.)]"
but i am not able to find/define the difference in words.
Any help would be appreciated.
Thanks
 
Roseanne Zhang
Ranch Hand
Posts: 1953
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
//a[following::x]
Select all a elements which has x in its following axis.
//a[following::x = .]
Select all a elements which has x in its following axis and the x node value equals the node a's value.
 
Vivek Saxena
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh , Now i get it.
Thanks you Roseanne.
Thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic