the domparser.getDocument() method returns the
a node that is really a document node. The same thing happens when
getChildNodes() is called instead of getFirstChild().
The problem is that this same code works for other
documents, but not this one. I was hoping other people have had this
problem.
----- Original Message -----
Sent: Tuesday, June 25, 2002 11:52
AM
Subject: RE: ClassCastException
Could it be the domparser.getDocument() (probably returns a Document
and not a Node). There are methods that return Node type or use the methods
that return NodeList- see api doc. Just a guess, I don't work with
DOM.
HTH,
-Will
I get the following exception when trying to
iterate over a documents child elements. It only happens the first
time, but I have moved the calling code so it only happens once and messes
up the initialization of my program. Here is the offending
code
...
domparser.parse(filename);
Node documentNode =
domparser.getDocument(); exception-> Node
documentChildNode = documentNode.getFirstChild();
and the accompanying stack trace:
java.lang.ClassCastException:
org.apache.xerces.dom.DeferredAttrNSImpl
at
org.apache.xerces.dom.DeferredDocumentImpl.synchronizeChildren(DeferredDocumentImpl.java:1590)
at
org.apache.xerces.dom.DeferredEntityImpl.synchronizeChildren(DeferredEntityImpl.java:179)
at
org.apache.xerces.dom.ParentNode.setReadOnly(ParentNode.java:928)
at
org.apache.xerces.dom.NamedNodeMapImpl.setReadOnly(NamedNodeMapImpl.java:395)
at
org.apache.xerces.dom.DocumentTypeImpl.setReadOnly(DocumentTypeImpl.java:347)
at
org.apache.xerces.dom.DeferredDocumentTypeImpl.synchronizeChildren(DeferredDocumentTypeImpl.java:219)
at
org.apache.xerces.dom.DocumentTypeImpl.getElements(DocumentTypeImpl.java:358)
at
org.apache.xerces.dom.ElementImpl.getDefaultAttributes(ElementImpl.java:872)
at
org.apache.xerces.dom.ElementImpl.setupDefaultAttributes(ElementImpl.java:850)
at
org.apache.xerces.dom.DeferredElementNSImpl.synchronizeData(DeferredElementNSImpl.java:155)
at
org.apache.xerces.dom.NodeImpl.setReadOnly(NodeImpl.java:1102)
at
org.apache.xerces.dom.ParentNode.setReadOnly(ParentNode.java:923)
at
org.apache.xerces.dom.ElementImpl.setReadOnly(ElementImpl.java:820)
at
org.apache.xerces.dom.ParentNode.setReadOnly(ParentNode.java:936)
at
org.apache.xerces.dom.DeferredEntityReferenceImpl.synchronizeChildren(DeferredEntityReferenceImpl.java:191)
at
org.apache.xerces.dom.ParentNode.getLastChild(ParentNode.java:273)
at
org.apache.xerces.dom.DeferredDocumentImpl.synchronizeData(DeferredDocumentImpl.java:1406)
at
org.apache.xerces.dom.DeferredDocumentImpl.synchronizeChildren(DeferredDocumentImpl.java:1449)
at
org.apache.xerces.dom.ParentNode.getFirstChild(ParentNode.java:263)
at VFS.VFS.load(VFS.java:110)
at VFS.VFSServer.run(VFSServer.java:145)
Does anyone know how I can access a documents
child elements without causing this exception? Is there something I
need to call first?
Thanks in advance
Bryan Mulvihill Software Developer AMCon Research
Inc.
|