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 bu...@apache.org on 2004/03/29 18:59:01 UTC

DO NOT REPLY [Bug 28022] New: - NullPointerException in normalizeDocument when normalizing childless Entity Reference

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=28022>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=28022

NullPointerException in normalizeDocument when normalizing childless Entity Reference

           Summary: NullPointerException in normalizeDocument when
                    normalizing childless Entity Reference
           Product: Xerces2-J
           Version: 2.6.2
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: DOM
        AssignedTo: xerces-j-dev@xml.apache.org
        ReportedBy: nnissar@ca.ibm.com
                CC: nddelima@ca.ibm.com


>From Neil Delima: 

Only entities that were referenced in the document contain their replacement 
text as child nodes.  So if an entity reference node that was not referenced in 
the parsed document, was created and appended to the DOM tree, its child node 
would be null.

Problem in DOMNormalizer:

expandEntityRef (parent, node);
parent.removeChild(node);
Node next = (prevSibling != null)?prevSibling.getNextSibling
():parent.getFirstChild();
// The list of children #text -> &ent;
// and entity has a first child as a text
// we should not advance
if (prevSibling !=null && next!=null && prevSibling.getNodeType()               
== Node.TEXT_NODE && next.getNodeType() == Node.TEXT_NODE) {
                return prevSibling;  // Don't advance                          
}

If a new entity reference with no children is created that does not correspond 
to an existing Entity node, next will always be null and a NPE gets thrown.  
This happens in the current case since in Xerces, children of entity nodes are 
null unless referenced in the document being parsed.  So the next!=null check 
is needed.

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