[ 
https://issues.apache.org/jira/browse/XERCESJ-1582?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

David Costanzo updated XERCESJ-1582:
------------------------------------
    Fix Version/s: 2.12.0

> Node prefix/namespace query methods throw an NPE on a document without a 
> document element
> -----------------------------------------------------------------------------------------
>
>                 Key: XERCESJ-1582
>                 URL: https://issues.apache.org/jira/browse/XERCESJ-1582
>             Project: Xerces2-J
>          Issue Type: Bug
>          Components: DOM (Level 3 Core)
>    Affects Versions: 2.9.1
>            Reporter: Andreas Veithen
>            Assignee: Michael Glavassevich
>            Priority: Minor
>             Fix For: 2.12.0
>
>
> According to appendix B.4 of the DOM Level 3 Core specification, calling 
> Node#lookupNamespaceURI on a Document node actually performs the lookup on 
> the document element. This is implemented by Xerces, but the code doesn't 
> take into account that the Document may be empty (or not have a document 
> element). On such Document instances, the lookupNamespaceURI throws a 
> NullPointerException.
> The issue can be demonstrated using the following code:
>         Document document = 
> DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
>         System.out.println(document.lookupNamespaceURI("p"));
> It is caused by the following piece of code in NodeImpl:
>         case Node.DOCUMENT_NODE : {   
>                 
> return((NodeImpl)((Document)this).getDocumentElement()).lookupNamespaceURI(specifiedPrefix);
>             }
> The issue has been observed with Xerces 2.9.1, but the code in the trunk is 
> unchanged.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to