You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@santuario.apache.org by "Peter De Maeyer (Jira)" <ji...@apache.org> on 2020/04/11 09:23:00 UTC

[jira] [Created] (SANTUARIO-534) DOMNamespaceContext does not implement the NamespaceContext contract correctly

Peter De Maeyer created SANTUARIO-534:
-----------------------------------------

             Summary: DOMNamespaceContext does not implement the NamespaceContext contract correctly
                 Key: SANTUARIO-534
                 URL: https://issues.apache.org/jira/browse/SANTUARIO-534
             Project: Santuario
          Issue Type: Bug
          Components: Java
    Affects Versions: Java 2.1.5
            Reporter: Peter De Maeyer
            Assignee: Colm O hEigeartaigh


{{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.

h3. 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.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)