cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bruno Dumon <br...@outerthought.org>
Subject Re: Error in org.apache.cocoon.xml.dom.DOMStreamer.NamespaceNormalizingDOMStreamer or xerces DocumentImpl
Date Wed, 23 Nov 2005 19:14:01 GMT
On Tue, 2005-11-22 at 16:47 +0100, Michael Wirz wrote:
> Hello Coocon User Mailing List,
> 
> During cocoon app development the following error arose using DOM-Documents
> and the SAX-Streaming of cocoon. Since I am not sure if its a bug in cocoons
> DOM->SAX Streamer or the Document Implementation of xerces I'd like to show
> it to you first. Maybe you can help deciding if it is to be forwarded to
> cocoon-dev
> or another place.
> 
> I built a DOM - Tree using the xerces DocumentImpl Documt-Class.
> I then added a root Node with a Text Element, initialized (erratically)
> with null.
> see below:
> 
> Document doc = new DocumentImpl();
> Element e = doc.createelement("rootNode");
> doc.appendChild(e);
> e.appendChild(doc.createTextNode(null));
> 
> This has been a valid DOM-Document and could be serialized using the
> org.apache.xml.serialize.XMLSerializer and written to a file successfully.
> 
> When using this DOM-Tree in an <xsp:expr> in cocoon a NullPointerException
> occurred:
> 
> Original Exception: java.lang.NullPointerException
> 	at org.apache.cocoon.xml.dom.DOMStreamer$NamespaceNormalizingDOMStreamer.dispatchChars(DOMStreamer.java:264)
> 	at org.apache.cocoon.xml.dom.DOMStreamer$NamespaceNormalizingDOMStreamer.startNode(DOMStreamer.java:471)
> 	at org.apache.cocoon.xml.dom.DOMStreamer$NamespaceNormalizingDOMStreamer.stream(DOMStreamer.java:229)
> 	at org.apache.cocoon.xml.dom.DOMStreamer.stream(DOMStreamer.java:150)
> 	at org.apache.cocoon.components.language.markup.xsp.XSPObjectHelper.xspExpr(XSPObjectHelper.java:309)
> 	at ... the xsp-compiled java src ...
> 
> I took a look at
> *org.apache.cocoon.xml.dom.DOMStreamer.NamespaceNormalizingDOMStreamer.
> dispatchChars looks like this:
> 
>         private final void dispatchChars(Node node) throws SAXException {
>             String data = ((Text) node).getData();
>             contentHandler.characters(data.toCharArray(), 0, data.length());
>         }
> 
> If getData() yields null, subsequent calls will fail; resulting in my
> NullPointerException.
> 
> I fixed my DOM-Tree making things work.
> Do we have to fix it in
> **org.apache.cocoon.xml.dom.DOMStreamer.NamespaceNormalizingDOMStreamer?
> Or is the DOM invalid according to the DOM Spec, in other words: is a
> null-Data-Element allowed in a TextNode?

You could look it up yourself too :-) I just had a quick look at the DOM
spec, but for me it is unclear whether it is allowed to be null or not.
It is not mentioned that it cannot be null, but it is neither mentioned
that it can be null, while other methods that do allow null values for
arguments do mention this.

-- 
Bruno Dumon                             http://outerthought.org/
Outerthought - Open Source, Java & XML Competence Support Center
bruno@outerthought.org                          bruno@apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message