File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

following::* doubt

 
Micheal Jacob
Ranch Hand
Posts: 89
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is XML File


This is XSL


What is the output & please explain.
 
Micheal Jacob
Ranch Hand
Posts: 89
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please ignore the above entry.
XML File :



XSL File :

What is the output & please explain.
 
Dan Drillich
Ranch Hand
Posts: 1183
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please try the following -

And

Happy New Year!
Dan
 
Roseanne Zhang
Ranch Hand
Posts: 1953
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is a simpler approach, use the following stylesheet on Micheal's original xml:

Result xml:

Then you count them by hand to see they match.
 
Micheal Jacob
Ranch Hand
Posts: 89
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Everybody,
Thanks for reply.
But we form pattern as //GGG/following::*
so it will search for all possible GGG node, we have two node names as GGG
for first GGG node there are 12 nodes for following, what abt second GGG node why we are not counting that.(<XXX><AAA> should come right ?)
Please explain.
 
Roseanne Zhang
Ranch Hand
Posts: 1953
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you read the result from my above post?
12
2
 
Micheal Jacob
Ranch Hand
Posts: 89
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Roseanne,
I have compiled your code.

u have only count(following::*) so it is giving 12 & 2
but if i have count(//GGG/following::*) without for-each, it should give me 14 right ?
Just i am putting this inside <template match="/">
Please correct me if i am wrong.
Micheal
 
Roseanne Zhang
Ranch Hand
Posts: 1953
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You only did it once, the first GGG's followings, that was why you got 12 only.
Be careful to learn how to interpret a node-set. There are many good tutorials on the web. I don't remember which one explains this better. But actually your practice result is the best tutor. Try different combinations/permutations in code, then you find your own answer. That is my way to learn it. I'm still learning...
 
Micheal Jacob
Ranch Hand
Posts: 89
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Roseanne
ya, well said.
But i am not convinced on this....i am using the same xml given by u and my xsl is


this gives me 2 and yes it suppose to give me 2 only.
but when i change //GGG/self::* to //GGG/following::* i should get 14 right ? it gives me 12.
is my question make sense ?
Micheal
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic