You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@xerces.apache.org by Seth Ladd <sh...@osfmail.isc.rit.edu> on 2000/01/03 03:10:17 UTC
Exception: DeferredTextImpl
Hello,
I'm sorry if this has been mentioned before on the mailing list. I
tried to look through the archives, but I didn't see this.
I am trying to use the latest Xerces-J parser, but I get an exception
when I try to access the first child from the root.
I get a java.lang.ClassCastException:
org.apache.xerces.dom.DeferredTextImpl exception thrown when I try to
execute the line:
child = (Element)trueroot.getFirstChild();
I'm not sure what to do, since I'm not sure what the exception message
is telling me. I am using the IBM JDK 1.1.8 JDK on Linux 2.2.13. The
Xerces-J parser is the latest from CVS.
Here is a code snipet:
DOMParser parser = new DOMParser();
parser.parse(filename);
Document doc = parser.getDocument();
Element trueroot = (Element)doc.getDocumentElement();
Element child = (Element)trueroot.getFirstChild();
Any hints or ideas would be greatly appreciated.
Thanks very much,
Seth
Re: Exception: DeferredTextImpl
Posted by Seth Ladd <sh...@osfmail.isc.rit.edu>.
> The first child of the result of getDocumentElement is not guaranteed
> to be an Element. The ClassCastException is telling you that you are
> trying to cast a Text Node into an ElementNode -- which doesn't work.
Thanks so much! I think I looked everywhere else for the solution to this
but right here. :( There was whitespace as the firstChild(), which is
where I was getting confused.
Thanks,
Seth
Re: Exception: DeferredTextImpl
Posted by Ted Leung <tw...@sauria.com>.
Seth,
The first child of the result of getDocumentElement is not guaranteed
to be an Element. The ClassCastException is telling you that you are
trying to cast a Text Node into an ElementNode -- which doesn't work.
Ted
----- Original Message -----
From: "Seth Ladd" <sh...@osfmail.isc.rit.edu>
To: <xe...@xml.apache.org>
Sent: Sunday, January 02, 2000 6:10 PM
Subject: Exception: DeferredTextImpl
> Hello,
>
> I'm sorry if this has been mentioned before on the mailing list. I
> tried to look through the archives, but I didn't see this.
>
> I am trying to use the latest Xerces-J parser, but I get an exception
> when I try to access the first child from the root.
>
> I get a java.lang.ClassCastException:
> org.apache.xerces.dom.DeferredTextImpl exception thrown when I try to
> execute the line:
>
> child = (Element)trueroot.getFirstChild();
>
> I'm not sure what to do, since I'm not sure what the exception message
> is telling me. I am using the IBM JDK 1.1.8 JDK on Linux 2.2.13. The
> Xerces-J parser is the latest from CVS.
>
> Here is a code snipet:
>
> DOMParser parser = new DOMParser();
> parser.parse(filename);
> Document doc = parser.getDocument();
> Element trueroot = (Element)doc.getDocumentElement();
> Element child = (Element)trueroot.getFirstChild();
>
> Any hints or ideas would be greatly appreciated.
>
> Thanks very much,
> Seth
>