xerces-j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrzej Roman Cichocki (JIRA)" <xerces-j-...@xml.apache.org>
Subject [jira] Created: (XERCESJ-1109) Non-DocumentImpl DOM implementation causes ClassCastExceptions.
Date Thu, 27 Oct 2005 16:01:55 GMT
Non-DocumentImpl DOM implementation causes ClassCastExceptions.
---------------------------------------------------------------

         Key: XERCESJ-1109
         URL: http://issues.apache.org/jira/browse/XERCESJ-1109
     Project: Xerces2-J
        Type: Bug
  Components: DOM (Level 3 Core)  
    Versions: 2.7.1    
 Environment: jdk1.5.0_04 on Linux
    Reporter: Andrzej Roman Cichocki


The documentation at http://xml.apache.org/xerces2-j/properties.html suggests that setting
the value of the http://apache.org/xml/properties/dom/document-class-name property to any
implementation of org.w3c.dom.Document should work.

In the following test DocumentWrapper wraps org.apache.xerces.dom.DocumentImpl. All methods
simply delegate to DocumentImpl except for createElementNS and createAttributeNS. These wrap
the objects returned by the underlying DocumentImpl in ElementWrapper and AttrWrapper respectively.
All methods in ElementWrapper and AttrWrapper simply delegate to the underlying Impl.

The aim is for Xerces to build a DOM tree consisting of wrapper instances which should behave
in exactly the same way as the underlying Impls. In practice the parser bombs with ClassCastExceptions:

java.lang.ClassCastException: ElementWrapper
	at org.apache.xerces.dom.ParentNode.internalInsertBefore(ParentNode.java:381)
	at org.apache.xerces.dom.ParentNode.insertBefore(ParentNode.java:282)
	at org.apache.xerces.dom.CoreDocumentImpl.insertBefore(CoreDocumentImpl.java:389)
	at org.apache.xerces.dom.NodeImpl.appendChild(NodeImpl.java:235)
	at NodeWrapper.appendChild(NodeWrapper.java:80)
	at org.apache.xerces.parsers.AbstractDOMParser.startElement(AbstractDOMParser.java:1014)
	at org.apache.xerces.parsers.AbstractDOMParser.emptyElement(AbstractDOMParser.java:1099)
	at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:277)
	at org.apache.xerces.impl.XMLNSDocumentScannerImpl$NSContentDispatcher.scanRootElementHook(XMLNSDocumentScannerImpl.java:738)
	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1754)
	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:323)
	at org.apache.xerces.parsers.XML11Configuration.parse(XML11Configuration.java:807)
	at org.apache.xerces.parsers.XML11Configuration.parse(XML11Configuration.java:737)
	at org.apache.xerces.parsers.XMLParser.parse(XMLParser.java:107)
	at org.apache.xerces.parsers.DOMParser.parse(DOMParser.java:225)
	at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:283)
	at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:98)
	at Main.main(Main.java:16)
java.lang.ClassCastException: AttrWrapper
	at org.apache.xerces.dom.AttributeMap.setNamedItem(AttributeMap.java:89)
	at org.apache.xerces.dom.ElementImpl.setAttributeNode(ElementImpl.java:549)
	at ElementWrapper.setAttributeNode(ElementWrapper.java:37)
	at org.apache.xerces.parsers.AbstractDOMParser.startElement(AbstractDOMParser.java:922)
	at org.apache.xerces.parsers.AbstractDOMParser.emptyElement(AbstractDOMParser.java:1099)
	at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:277)
	at org.apache.xerces.impl.XMLNSDocumentScannerImpl$NSContentDispatcher.scanRootElementHook(XMLNSDocumentScannerImpl.java:738)
	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1754)
	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:323)
	at org.apache.xerces.parsers.XML11Configuration.parse(XML11Configuration.java:807)
	at org.apache.xerces.parsers.XML11Configuration.parse(XML11Configuration.java:737)
	at org.apache.xerces.parsers.XMLParser.parse(XMLParser.java:107)
	at org.apache.xerces.parsers.DOMParser.parse(DOMParser.java:225)
	at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:283)
	at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:98)
	at Main.main(Main.java:23)

The source code and class files to reproduce these exceptions are in the attached jar. It
is runnable as follows provided xercesImpl.jar is in the same directory:

	java -jar xerces-bug.jar



-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


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


Mime
View raw message