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 13:14:00 UTC

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

    [ https://issues.apache.org/jira/browse/SANTUARIO-534?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17081275#comment-17081275 ] 

Peter De Maeyer commented on SANTUARIO-534:
-------------------------------------------

Fixed done:
# Added {{DOMNamespaceContextTest}} with tests illustrating everything that is broken about {{DOMNamespaceContext}}. {{DOMNamespaceContext}} is essentially an adapter now adapting the the {{Node}} API to fit the {{NamespaceContext}} API.
# Fixed {{DOMNamespaceContext}} such that it implements the {{NamespaceContext}} contract correctly.
# Added {{DOMNamespaceContext.setContext(Node context)}} to allow reusing a single instance with multiple {{Node}} contexts, in anticipation of using it in SANTUARIO-532.

> 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
>            Priority: Minor
>         Attachments: SANTUARIO-534.patch
>
>
> {{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)