Hi Niranjan,
It looks like the failure is caused by the fact that there is a declaration for an entity named "sup" in the DTD, as well as a declaration for an element named "sup". A default attribute declaration for the element "sup" is getting associated with the entity declaration instead of the element declaration. When the deferred DOM is expanded, the unexpected attribute node that is associated with the entity declaration causes the ClassCastException to be thrown.
You should be able to reproduce the problem with the following test.
<?xml version="1.0"?>
<!DOCTYPE root [
<!ENTITY inner "val">
<!ELEMENT inner EMPTY>
<!ELEMENT root (inner)>
<!ATTLIST inner attr CDATA "attr-val">
]>
<root>
<inner/>
</root>
I've attached a patch that hasn't undergone thorough testing yet.
You can either try applying that patch, or as a work-around, you can try turning off the deferred DOM feature on the parser <http://apache.org/xml/features/dom/defer-node-expansion>.
I hope that helps.
Thanks,
Henry
------------------------------------------------------------------
Henry Zongaro XML Parsers development
IBM SWS Toronto Lab Tie Line 969-6044; Phone (905) 413-6044
mailto:[EMAIL PROTECTED]
| Arnaud Le Hors/Cupertino/IBM@IBMUS
02/04/15 04:21 PM
|
To: Niranjan Kundapur <[EMAIL PROTECTED]>, [EMAIL PROTECTED] cc: Subject: Re: ClassCastException: org.apache.xerces.dom.DeferredAttrNSImpl onNodeList.getLength() |
It seems to be in Xerces because I can reproduce the bug with a
different application (dom.Counter). However, I spent a couple of hours
on Friday trying to figure out where it comes from without any success.
The error doesn't seem to make any sense whatsoever. There is no
explicit cast involved anywhere in this part of the code. The exception
seems to come from nowhere. I traced the program both with println
statements and in a debuger but got the same unconclusive results. Until
I can locate the problem I can't neither tell you what it's about nor
how to possibly workaround it.
I'm not sure how much more time I'll be able to spend on this. If
anybody else wants to have a look, be my guest!
--
Arnaud Le Hors - IBM, XML Standards Strategy Group / W3C AC Rep.
Niranjan Kundapur wrote:
>
> Hello,
>
> I was wondering if you could give me some more info on this issue. Whether
> it is a Xerces issue, or how I can fix something on my application side.
>
> Thanks for looking into this,
> - Niranjan
>
> -----Original Message-----
> From: Arnaud Le Hors [mailto:[EMAIL PROTECTED]]
> Sent: Friday, April 12, 2002 1:21 PM
> To: [EMAIL PROTECTED]
> Subject: Re: ClassCastException:
> org.apache.xerces.dom.DeferredAttrNSImpl on NodeList.getLength()
>
> 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.
Index: DeferredDocumentImpl.java
===================================================================
RCS file:
/home/cvspublic/xml-xerces/java/src/org/apache/xerces/dom/DeferredDocumentImpl.java,v
retrieving revision 1.43
diff -u -r1.43 DeferredDocumentImpl.java
--- DeferredDocumentImpl.java 12 Apr 2002 01:13:52 -0000 1.43
+++ DeferredDocumentImpl.java 16 Apr 2002 22:56:11 -0000
@@ -806,7 +806,9 @@
nchunk = index >> CHUNK_SHIFT;
nindex = index & CHUNK_MASK;
- if (getChunkValue(fNodeName, nchunk, nindex) == elementName) {
+ if (getChunkIndex(fNodeType, nchunk, nindex) ==
+ NodeImpl.ELEMENT_DEFINITION_NODE
+ && getChunkValue(fNodeName, nchunk, nindex) == elementName) {
return index;
}
}
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
