[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: not() function behaving differently in java 1.4 a

Subject: RE: not() function behaving differently in java 1.4 and 1.5 environment.
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Thu, 2 Aug 2007 21:30:00 +0100
RE:   not() function behaving differently in java 1.4 a
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/

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.