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 Niranjan Kundapur <ni...@air2web.com> on 2002/04/12 15:28:03 UTC

ClassCastException: org.apache.xerces.dom.DeferredAttrNSImpl on N odeList.getLength()

Maybe I should have sent this email to the dev list. Sorry for sending it to
both lists. Thanks - Niranjan

-----Original Message-----
From: Niranjan Kundapur 
Sent: Thursday, April 11, 2002 3:41 PM
To: 'xerces-j-user@xml.apache.org'
Subject: ClassCastException: org.apache.xerces.dom.DeferredAttrNSImpl on
NodeList.getLength()


Hello,

I am trying to parse the XHTML1.1 document (from
http://www.w3.org/TR/xhtml11)) included below and I get a
"ClassCastException: org.apache.xerces.dom.DeferredAttrNSImpl" when I try to
do a NodeList.getLength() on the returned doc. I observed it while running
other methods also; Node.getName if I remember correctly.

I am using Xerces2.0.0. I get the same exception with 2.0.1 also (different
line numbers, though). I have set validation and namespaces to true. The
code outline is included below. I will appreciate any advice on resolving
this. 

Thank you,
Niranjan

EXCEPTION
=========
java.lang.ClassCastException: org.apache.xerces.dom.DeferredAttrNSImpl
        at
org.apache.xerces.dom.DeferredDocumentImpl.synchronizeChildren(DeferredDocum
entImpl.java:1590)
        at
org.apache.xerces.dom.DeferredEntityImpl.synchronizeChildren(DeferredEntityI
mpl.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(DeferredD
ocumentTypeImpl.java:219)
        at
org.apache.xerces.dom.ParentNode.hasChildNodes(ParentNode.java:232)
        at
org.apache.xerces.dom.DeepNodeListImpl.nextMatchingElementAfter(DeepNodeList
Impl.java:207)
        at
org.apache.xerces.dom.DeepNodeListImpl.item(DeepNodeListImpl.java:182)
        at
org.apache.xerces.dom.DeepNodeListImpl.getLength(DeepNodeListImpl.java:153)
        at XMLTest.main(XMLTest.java:73)

 CODE
======
private DocumentBuilderFactory m_dbf = DocumentBuilderFactory.newInstance();
private DocumentBuilder        m_db  = null;
.
 .
  m_dbf.setValidating(true);
  m_dbf.setNamespaceAware(true);
  .
  .
  m_db = m_dbf.newDocumentBuilder();
  .
  .
  doc = m_db.parse(theSource);
  NodeList nl = doc.getElementsByTagNameNS("http://www.w3.org/1999/xhtml",
"html");
  System.out.println("nl.getLength: "+nl.getLength());


XHTML1.1 file (from http://www.w3.org/TR/xhtml11)
=================================================
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >
<head>
<title>Virtual Library</title>
</head>
<body>
<p>Moved to <a href="http://vlib.org/">vlib.org</a>.</p>
</body>
</html>

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org


Re: ClassCastException: org.apache.xerces.dom.DeferredAttrNSImpl on NodeList.getLength()

Posted by Arnaud Le Hors <le...@us.ibm.com>.
Ok, I can easily reproduce it so I'll have a look at it. Hold on...
-- 
Arnaud  Le Hors - IBM, XML Standards Strategy Group / W3C AC Rep.

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org