You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Nicholas W. (JIRA)" <ji...@apache.org> on 2009/10/07 11:26:31 UTC

[jira] Commented: (BETWIXT-67) Betwixt does not correctly implement namespace scoping

    [ https://issues.apache.org/jira/browse/BETWIXT-67?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12762958#action_12762958 ] 

Nicholas W. commented on BETWIXT-67:
------------------------------------

Proposed patch will produce the following XML with above scenario

<oai_dc:dc xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/">
    <dc:title xmlns:dc="http://purl.org/dc/elements/1.1/">Sample Title</dc:title>
    <dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Sample Creator</dc:creator>
    <dc:publisher xmlns:dc="http://purl.org/dc/elements/1.1/">Sample Publisher</dc:publisher>
    <dc:description xmlns:dc="http://purl.org/dc/elements/1.1/">Sample Description</dc:description>
    <dc:identifier xmlns:dc="http://purl.org/dc/elements/1.1/">Sample Identifier</dc:identifier>
    <dc:subject xmlns:dc="http://purl.org/dc/elements/1.1/">Sample Subject</dc:subject>
  </oai_dc:dc>

Not beautiful, but it is correct.


> Betwixt does not correctly implement namespace scoping
> ------------------------------------------------------
>
>                 Key: BETWIXT-67
>                 URL: https://issues.apache.org/jira/browse/BETWIXT-67
>             Project: Commons Betwixt
>          Issue Type: Bug
>            Reporter: Nicholas W.
>            Priority: Critical
>         Attachments: Betwixt-67-proposed.patch
>
>
> According to: http://www.w3.org/TR/xml-names/#scoping 
> The scope of a namespace declaration declaring a prefix extends from the beginning of the start-tag in which it appears to the end of the corresponding end-tag, excluding the scope of any inner declarations with the same NSAttName part. In the case of an empty tag, the scope is the tag itself.
> Such a namespace declaration applies to all element and attribute names within its scope whose prefix matches that specified in the declaration. 
> Namespace declarations are handled in the class AbstractBeanWriter in method addNamespaceDeclarations
> Each new namespace declaration is added to namespacesDeclared and written out to the attributes of an element just once. The declaration is made just once in any one object as it is written out. The result is:
> Using a  dot betwixt file like this:
> <?xml version="1.0"?>
> <info primitiveTypes="element">
>   <element name="dc" uri="http://www.openarchives.org/OAI/2.0/oai_dc/">
>     <element name="title" property="title" uri="http://purl.org/dc/elements/1.1/"/>
>     <element name="creator" property="creator" uri="http://purl.org/dc/elements/1.1/"/>
>     <element name="publisher" property="publisher" uri="http://purl.org/dc/elements/1.1/"/>
>     <element name="description" property="description" uri="http://purl.org/dc/elements/1.1/"/>
>     <element name="identifier" property="identifier" uri="http://purl.org/dc/elements/1.1/"/>
>     <element name="subject" property="subject" uri="http://purl.org/dc/elements/1.1/"/>
>   </element>
> </info>
> And with the beanwriter having  extra configuration of the NamespacePrefixMapper like this:
> prefixMapper.setPrefix("http://purl.org/dc/elements/1.1/", "dc");
> prefixMapper.setPrefix("http://www.openarchives.org/OAI/2.0/oai_dc/", "oai_dc");
> The XML generated is like this:
> <oai_dc:dc xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/">
>     <dc:title xmlns:dc="http://purl.org/dc/elements/1.1/">Sample Title</dc:title>
>     <dc:creator>Sample Creator</dc:creator>
>     <dc:publisher>Sample Publisher</dc:publisher>
>     <dc:description>Sample Description</dc:description>
>     <dc:identifier>Sample Identifier</dc:identifier>
>     <dc:subject>Sample Subject</dc:subject>
>   </oai_dc:dc>
> Which is wrong. The namespace declaration should be in the parent element, or repeated in all the child elements.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.