Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
Java 2.1.5
-
None
Description
DOMNamespaceContext implements NamespaceContext, but it does not obey the contract defined by NamespaceContext. In addition, it is needlessly stateful, which hampers flexibility and reuse.
- getPrefixes(String namespaceURI) must return all prefixes for a given namespace URI (a corner case), however, the implementation returns all prefixes, ignoring the namespace URI. Luckily, this method is not used in practice by the framework, so since it's broken anyway and not used it's better to throw UnsupportedOperationException.
- It does not correctly treat constants such as XMLConstants.XMLNS_ATTRIBUTE correctly, as explained in the Javadoc of NamespaceContext.getPrefix(String namespaceURI) and getNamespaceURI(String prefix).
- It needlessly builds up a map, and rolls its own implementation of detecting "xmlns" attributes, rather than relying on the Node API for that.
Solution
Implement the class as an adapter, adapting the Node API to the NamespaceContext API.
Leverage methods such as Node.lookupPrefix.
Beware of the differences in both APIs: Node generally uses null to denote "the default value", while NamespaceContext uses "" (the empty string) for that.
Attachments
Attachments
Issue Links
- is depended upon by
-
SANTUARIO-532 User-defined and delayed evaluation of which XML elements need to be secured
- Open