You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by Jeffrey Rodriguez <je...@hotmail.com> on 2000/06/16 06:10:44 UTC
Re: bug in serializing dom ?? - Fix is in CVS
Just fixed the DOM serializing bug.
I want to also make it clear that the term "serializing" is overloaded.
To some people in this group serializing means using the serializer API
from org.apache.xml.serialize to format a DOM for example ( like
pretty printing ). To some other people the term means to use the
Java Object Serialization on the DOM.
The bug I just fixed is with the latter.
Between version 1.0.3 and 1.0.4 there were changes made to the
org.apache.xerces.dom package and a bug was introduced that made it
possible to save nodes in an incorrect state.
The fix is in cvs: org.apache.xerces.dom.ParentNode and
org.apache.xerces.dom.ChildAndParentNode.
Thanks,
Jeffrey Rodriguez
XML Development
IBM Cupertino
>From: "Stefan Rauch" <sr...@uos.de>
>Reply-To: xerces-j-dev@xml.apache.org
>To: <xe...@xml.apache.org>
>Subject: bug in serializing dom ??
>Date: Wed, 14 Jun 2000 09:55:30 +0200
>
>Hi!
>
>I posted this some time ago in the ibm "xml-parser for java" newsgroup but
>didin't get an answer.
>I would be glad if anybody could give me a hint, what I'm missing. I had a
>rough view on the mailing lists archive but couldn't find a solution there
>- so here is my question:
>
>I've got a problem with the newer xerces-releases (1.04 - May 2000 and
>higher - up to xerces1.1.1)
>
>I created several classes using the org.apche.xerces.parsers.DOMParser and
>all of them work fine with the xerces.jar from xerces1.03, but right now
>they fail whenever I try to access an instance of the DocumentImpl which
>has been serialized before.
>
>A simple example (existing of two classes - The first class reads in xml,
>serializes it and writes it to a ObjectOutputStream [DOMOut] and the second
>one reads the serialized dom from ObjectInputStream and tries to get a
>given searchelement [DOMIn]):
>
>[DOMOut]:
>...
> DOMParser parser = new DOMParser();
> FileReader in = new FileReader(argv[0]);
> InputSource ins = new InputSource(in);
> parser.parse(ins);
> DocumentImpl doc = (DocumentImpl)parser.getDocument();
> ObjectOutputStream out = new ObjectOutputStream(System.out);
> out.writeObject(doc); out.flush();
>...
>[DOMIn]:
>...
> ObjectInputStream in = new ObjectInputStream(System.in);
> DocumentImpl doc = (DocumentImpl) in.readObject();
> NodeList nl = doc.getElementsByTagName(argv[0]);
> if (nl.getLength()==0)
> System.out.println(argv[0] + ": is not in the document!");
> else {
> NodeImpl node = (NodeImpl) nl.item(nl.getLength()-1);
> System.out.println(node.getNodeName() + ": " +
>(node.getFirstChild()).getNodeValue());
> }
>...
>
>This is what I do with the classes:
>
>javac DOMOut.java
>javac DOMIn.java
>java DOMOut xmltestfile.xml > xx
>
>This works so far
>
>java DOMIn searchelem < xx
>
>This one breaks! I get the following exception (using xerces1.04, but it's
>very similar to the one using xerces1.1.1):
>java.lang.NullPointerException:
> at
>org.apache.xerces.dom.DeferredDocumentImpl.clearChunkIndex(DeferredDocumentImpl.java:1534)
> at
>org.apache.xerces.dom.DeferredDocumentImpl.getNodeType(DeferredDocumentImpl.java:1036)
> at
>org.apache.xerces.dom.DeferredDocumentImpl.getNodeType(DeferredDocumentImpl.java:1020)
> at
>org.apache.xerces.dom.DeferredDocumentImpl.synchronizeChildren(DeferredDocumentImpl.java,
>Compiled Code)
> at
>org.apache.xerces.dom.ParentNode.hasChildNodes(ParentNode.java:241)
> at
>org.apache.xerces.dom.DeepNodeListImpl.nextMatchingElementAfter(DeepNodeListImpl.java,
>Compiled Code)
> at
>org.apache.xerces.dom.DeepNodeListImpl.item(DeepNodeListImpl.java,
>CompiledCode)
> at
>org.apache.xerces.dom.DeepNodeListImpl.getLength(DeepNodeListImpl.java:151)
> at IbmDOMIn2.main(IbmDOMIn2.java:30)
>
>Where IbmDOMIn2.main 30 is the following line:
> if (nl.getLength()==0)
>
>Some Notes:
>The DocumentImpl exists. I tried it out by printing out the docs last
>Node's Value.
>Even if use the wildcard (*) in doc.getElementsByTagName() the returning
>NodeList seems to be broken.
>It is note an error in getLength(). If I call (e.g.) nl.item() first
>there's also a NullPointerException
>
>Are there any changes between xerces1.03 and xerces1.04 in Serialization
>I'm missing?
>As I mentioned before this example works fine with xerces1.03 but I would
>like to use the newer versions...
>I would be very pleased if anyone could help me soon!
>
>Thanks
>
>Stefan.
>
>
________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com