This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes Problem with xalan in a comparison along xpath axis Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Problem with xalan in a comparison along xpath axis" Watch "Problem with xalan in a comparison along xpath axis" New topic
Author

Problem with xalan in a comparison along xpath axis

Nicolas Stern
Ranch Hand

Joined: Apr 26, 2002
Posts: 57
Hi everybody,

I'm confronted with the following using xalan for a transformation: It seems that the result of a comparison between two values returns always true when I obtain the value along the following-sibling axe.

This is my source xml


.. and the stylesheet


Using xalan , both "if" statements evaluate to true. Output is always:


Using the xmlSpy internal xsl engine, the result of the comparison is as expected.

Thanks for any advice in advance.

Cheers - Nic
[ November 15, 2006: Message edited by: Nicolas Stern ]
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Right. That's because "following-sibling::value" returns a node-set containing all the following siblings. And when you compare a string to a node-set, as you do later, the comparison is true if any of the nodes in the node-set are equal to the string.

Did you mean "following-sibling::value[1]"?
Nicolas Stern
Ranch Hand

Joined: Apr 26, 2002
Posts: 57
Hi Paul,

Thanks for your answer! restriction on the position of the value element is the solution. Topic can be closed.

I was not aware of the correct usage of following-sibling until I encountered this problem with this Xalan Version (2.7.0).

Still puzzled by the output difference when using Spy internal xsl engine and Xalan 2.7.

Thanks !
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Problem with xalan in a comparison along xpath axis
 
Similar Threads
XSLT/XPath - Find unique text node value
Walk distinct values in xsl key 4 at a time
xsl:if and XPath
XSL question: position() strangeness
XSLT Help