xsl-list
[Top] [All Lists]

RE: [xsl] not() function behaving differently in java 1.4 and 1.5 environment.

2007-08-02 13:30:50
Looks like a bug. You are presumably using Xalan, so you should report it
there.

But it's likely to be a bug in the old version that's fixed in the new.
Can't be sure from your description.

On a dry run we found the value of variable ($value) is null. 

There's no such thing as null in XPath.

One possibility is that $value is a result tree fragment containing a
document node with no children. This exhibits rather surprising behaviour
and products have been known to get it wrong. For such a value, not($value)
should give false(), $value='' should give true. This is consistent with the
1.5 results you are seeing.


 The matrix below explains different test scenarios in which 
we ran the test changing java version and replacing 
not($value) with $value=''.

Java Version                                  Syntax Used
Test Result   
--------------------------------------------------------------
----------
------------------------------------------
 1.4                          <xsl:when test="not($value) and
position() = 1">YES</xsl:when>                   True 
 1.4                          <xsl:when test="$value = '' and
position() = 1">YES</xsl:when>                              False     
 1.5                          <xsl:when test="not($value) and
position() = 1">YES</xsl:when>                    False       
 1.5                          <xsl:when test="$value  = '' and
position() = 1">YES</xsl:when>                    True        

The first test case is what the xsl originally looked like. 
The same test fails in java 1.5 environment. Interestingly 
changing the not() function with operator = (see test# 4), 
the xsl works fine.

We have a couple of questions for this behavior:

*     Is there a difference in how a null and an empty string('') are
interpreted in java 1.4 and java 1.5?

The XPath specification hasn't changed between java releases, if that's what
you mean. And there's no such thing as a null in XPath.


*     Are the semantics of the statements we are using for not() and
the = operator equivalent?

No. Given a node with a zero-length string value, boolean($node) returns
true and $node='' also returns true.

*     Does XSL distinguish between null value and an empty string
('')?


Not applicable, there's no such thing as null in XSLT/XPath.

Michael Kay
http://www.saxonica.com/


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>