| Author |
A question on Xpath
|
jim yin
Ranch Hand
Joined: Aug 15, 2002
Posts: 111
|
|
The following is an example about "following" axis from an Xpath tutorial (Zvon), (1) and (2) are added by me to show the results. (1) is easy to understand, why (2)? Thanks. //ZZZ/following::*
|
 |
Mapraputa Is
Leverager of our synergies
Sheriff
Joined: Aug 26, 2000
Posts: 10065
|
|
|
You probably confuse "following" axis with "descendant". What you expect is "descendant"; "following" means "all the nodes following the context node in the document order".
|
Uncontrolled vocabularies
"I try my best to make *all* my posts nice, even when I feel upset" -- Philippe Maquet
|
 |
jim yin
Ranch Hand
Joined: Aug 15, 2002
Posts: 111
|
|
Thank you. Its more clear to me now. But why FFF is included, bit AAA is not?
Originally posted by Mapraputa Is: You probably confuse "following" axis with "descendant". What you expect is "descendant"; "following" means "all the nodes following the context node in the document order".
|
 |
Dan Drillich
Ranch Hand
Joined: Jul 09, 2001
Posts: 1121
|
|
Part of the tree looks like - AAA / \ / \ BBB(1c) XXX / | \ / | \ CCC ZZZ FFF(1a)(1b) \ \ GGG I denoted the text a bit differently. The three 1s became 1a, 1b and 1c. When I ran the template in XML Spy - <xsl:template match="/"> <xsl:apply-templates select="//ZZZ/following::*"/> </xsl:template> I got 1a, 1b and the 2s. I _didn't_ get 1c. I think 1c is a text node, which descends from BBB. It's not clear to me whether 1c follows ZZZ or not. Any ideas? Thanks, Dan
|
William Butler Yeats: All life is a preparation for something that probably will never happen. Unless you make it happen.
|
 |
Dan Drillich
Ranch Hand
Joined: Jul 09, 2001
Posts: 1121
|
|
Sorry ;-( Let's try - ............AAA.............. ........../....\............. ........./......\............ .........BBB(1c).XXX......... ......./..|.\................ ....../...|..\............... .....CCC.ZZZ.FFF(1a)(1b)..... ...............\............. ................\............ ...............GGG...........
|
 |
Dan Drillich
Ranch Hand
Joined: Jul 09, 2001
Posts: 1121
|
|
|
BTW, the Apache Xalan XSLT processor gave me the same result (no 1c).
|
 |
Mapraputa Is
Leverager of our synergies
Sheriff
Joined: Aug 26, 2000
Posts: 10065
|
|
Not sure what 1c is, but if it is empty element, you may not to get it in the output because it is empty. Have you tried XPath Visualizer? Very tool.
|
 |
Dan Drillich
Ranch Hand
Joined: Jul 09, 2001
Posts: 1121
|
|
Mapraputa, 1C is text following the </FFF> tag. It will be held in a text node and its parent is BBB. BBB, therefore, will have the following children (and maybe several empty text nodes), in this order - CCC,ZZZ,FFF and 1C. So, isn't 1C in the following axis of ZZZ? Thanks, Dan
|
 |
 |
|
|
subject: A question on Xpath
|
|
|