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 !
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
Joined: Apr 24, 2002
Posts: 58
posted
0
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
Joined: Nov 14, 2000
Posts: 1953
posted
0
//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.