cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Carsten Ziegeler" <cziege...@sundn.de>
Subject [C2]: Patch for namespace handling (NamespacesTable)
Date Fri, 27 Oct 2000 07:21:32 GMT
As I posted last week, we had some problems with the XPathAPI and the new XalanJ2. Now, thanks
to Gary Peskin these problems are tracked down to the namespace handling of the DOMBuilder
inside cocoon:

Gary Peskin wrote:
> 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

So here is a patch for the NamespacesTable class which simply sets the namespaceURI to null
if it has the length of zero.

Index: NamespacesTable.java
===================================================================
RCS file: /home/cvspublic/xml-cocoon/src/org/apache/cocoon/xml/Attic/NamespacesTable.java,v
retrieving revision 1.1.2.1
diff -r1.1.2.1 NamespacesTable.java
218c218,219
<         name.uri=uri;
---
>         if (uri.length() > 0) name.uri=uri;
>         else name.uri=null;


Regards
Carsten Ziegeler

Open Source Group              sunShine - Lighting up e:Business
================================================================
Carsten Ziegeler, S&N AG, Klingenderstrasse 5, D-33100 Paderborn
www.sundn.de                           mailto:cziegeler@sundn.de 
================================================================

Mime
View raw message