• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Confused with Xpath expression! Need Help.

 
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any help would great!
Waiting.
Thanks
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 1953
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oh , Now i get it.
Thanks you Roseanne.
Thanks
 
Oh. Hi guys! Look at this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic