It's not a secret anymore!
The moose likes Product and Other Certifications and the fly likes Need Help with XSLT Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Product and Other Certifications
Bookmark "Need Help with XSLT" Watch "Need Help with XSLT" New topic

Need Help with XSLT

Vivek Saxena
Ranch Hand

Joined: Apr 24, 2002
Posts: 58
I just started the reading of XSLT tutorial from and I am confused with very first example.
Original Files:

XML File:

XSL File:

Output File:

Up to This point everything is clear. We are using Xpath expression ="//title"/ and this is why we are getting the output file.
But when I tried to change the XML File with same style sheet it didn�t give me the expected output. The output file is still the same old file.

Changed XML File:

Output File:

Why it didn�t pick the second �title� element. Even though we are using the Xpath expression �//title�?

Please explain it?
[ March 05, 2003: Message edited by: Vivek Saxena ]
Madhan Ramalingam

Joined: Aug 22, 2002
Posts: 7
must because of the typo - > <titel>XML</title>
"titel" instead of "title"
Vivek Saxena
Ranch Hand

Joined: Apr 24, 2002
Posts: 58
No Not because of this, because my XML file is correct.

I did this typo when i was writing this post.
Please help me!, looking forward for some help.
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040
The value-of function of XSLT produces a node not a node set. If more than one values are possible, then it produces the "nearest one".
If I understood that right, I am thinking it would output the "title" element nearest to the axes, in this case it is "/decendant-or-self::" (for //, right?).
So the output is (nearest to the root node "/") will be seen. Hence, the result.
Anyone else has a different view, feel free....
- madhav

Take a Minute, Donate an Hour, Change a Life
Vivek Saxena
Ranch Hand

Joined: Apr 24, 2002
Posts: 58
Thanks Madhav,
I think you are absolutely right. This was a big confusion for me but I guess it is over now.
Thanks again!
I agree. Here's the link:
subject: Need Help with XSLT
It's not a secret anymore!