Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Preceding siblings

 
Jaysakthy Muthuvelu
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,
In zvon tutorial the following question has this answer 1,2,3,4 nodes.
Iam fine with 2,3,4 nodes since they r preceding siblings,but 1st node <BBB> is the parent of <ccc/>. How come they r telling it's the preceding sibling. Plz clarify me.

//CCC/preceding-sibling::*

<AAA>
<BBB> ------- 1
<CCC/>
<DDD/>
</BBB> ------
<XXX> ------- 4
<DDD>
<EEE/> ----------2
<DDD/> ----------3
<CCC/>
<FFF/>
<FFF>
<GGG/>
</FFF>
</DDD>
</XXX> -----------
<CCC>
<DDD/>
</CCC>
</AAA>
Thanks
shakthy
 
Arun Mishra
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jay,
I think it is looking for last CCC element, from which BBB obviously is preceding sibling.
<AAA>
<BBB>
<CCC/>
<DDD/>
</BBB>
<XXX>
<DDD>
<EEE/>
<DDD/>
<CCC/>
<FFF/>
<FFF>
<GGG/>
</FFF>
</DDD>
</XXX>
<CCC> <------ last CCC Element
<DDD/>
</CCC>
</AAA>
Please corect me if I am wrong.

Thanks,
Arun
 
Dan Drillich
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Arun is right!
BTW, _all_ the output is from the last CCC element.
Cheers,
Dan
 
Jaysakthy Muthuvelu
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Guys!
Now iam clear.
 
Roseanne Zhang
Ranch Hand
Posts: 1953
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Dan Drillich:
BTW, _all_ the output is from the last CCC element.

No, they are not all from the last CCC element. See the more readable version follow:

BTW, please use "code" button UBB to format your code, which will certainly save yours and others time.
Thanks!
 
Dan Drillich
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Roseanne,
Please be kind to check the following -

and -

Cheers,
Dan
 
Roseanne Zhang
Ranch Hand
Posts: 1953
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dan,
The problem is we don't have any text in the xml, which causes the undesired result. I changed the stylesheet to make it be able to tell some thing as well as well-formated XML.
XML sourece

XSL sourece

XML result

Thanks for giving me a chance!
Cheers
 
Dan Drillich
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think both of us are right. You for the explanation about the siblings and me about the output of ------- 1 and ----------2 etc.
Cheers,
Dan
 
Roseanne Zhang
Ranch Hand
Posts: 1953
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sure, that is a team work.
We all work together to make a difference!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic