While trying to use Document.getIdentifier() I ran into a bug in
DeferredDocumentImpl.synchronizeData(). The basic problem is in the loop
starting at line 1282. As the loop discovers identifier nodes it creates them
and sets the identifier index to -1. However, the loop also depends on the
identifier index to find the path to the root node. After the first pass thru the
loop a path to the root is no longer available (the first identifier index was set to -1).
 I put in a hack to find the path from the document root, but a better solution is
needed.
 
To recreate the problem generate a document with elements that have  ID type
attributes. Then call document.getIdentifier("IDAttributeName"). A ClassCastException
should occur.
 
Charles Simpson
Adhesive Software Inc. (http://www.adhesive.com)
mailto://[EMAIL PROTECTED]
 

cvs diff DeferredDocumentImpl.java (in directory E:\xml\xml-xerces\java\src\org\apache\xerces\dom)

Index: DeferredDocumentImpl.java

===================================================================

RCS file: /home/cvspublic/xml-xerces/java/src/org/apache/xerces/dom/DeferredDocumentImpl.java,v

retrieving revision 1.8

diff -r1.8 DeferredDocumentImpl.java

1282c1282

< for (int j = path.size() - 2; j >= 0; j--) {

---

> for (int j = path.size() - 1; j >= 0; j--) {

1285c1285

< while (child != null) {

---

> while (child != null && child != place) {

1293c1293,1304

< child = child.getNextSibling();

---

> Node newChild = child;

> if( child.hasChildNodes() ) {

> newChild = child.getFirstChild();

> } else if( (newChild = child.getNextSibling()) == null ) {

> while( (newChild = child) != place ) {

> child = newChild.getParentNode();

> newChild = child;

> if( (newChild = child.getNextSibling()) != null )

> break;

> }

> }

> child = newChild;

*****CVS exited normally with code 1*****

Reply via email to