cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gary L Peskin <ga...@firstech.com>
Subject Re: AW: Xalan2: XpathAPI Problem
Date Thu, 26 Oct 2000 15:29:38 GMT
Carsten Ziegeler wrote:
> After a little bit of investigation I found out the really difference between
> your example and mine is the namespaceURI of the node in question.
> In your example it is simply null (no object), in my example it is an empty
> string of length 0.
> So I assume that the testing of the namespaceURI in XalanJ2 only test for null
> or not null and not for an empty string.

Carsten --

I saw Joe's earlier message about null namespaces and I just wanted to
add a little something after looking at your example.  I notice that you
use org.apache.cocoon.xml.dom.DomBuilder to build the DOM.  The problem
is that in SAX2, if there is no namespace associated with an element,
startElement is called with a zero length string
(http://www.megginson.com/SAX/Java/javadoc/org/xml/sax/ContentHandler.html#startElement).

This is not a null value for the namespaceURI parameter but an empty
string (ie "").

However, DOM Level 2
(http://www.w3.org/TR/2000/PR-DOM-Level-2-Core-20000927/core.html#Namespaces-Considerations)
specifies:

"Note that because the DOM does no lexical checking, the empty string
will be treated as a real namespace URI in DOM Level 2 methods.
Applications must use the value null as the namespaceURI parameter for
methods if they wish to have no namespace."

It is up to your (or DOMBuilder's) startElement method to take the empty
string passed to it and convert that to a null when calling
createElementNS.  It does not seem to do that in it's present
implementation.

So, DOMBuilder.startElement() is actually telling createElementNS to
create an element with a namespaceURI of the empty string.  Because of
the problems that this entails, which Joe mentioned, this is probably
not a good thing.

If you are going to continue to use DOMBuilder, you might want to submit
this correction.  Then your XPathAPI call should work with no problems.

HTH,
Gary

Mime
View raw message