commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nicholas W. (JIRA)" <>
Subject [jira] Created: (BETWIXT-67) Betwixt does not correctly implement namespace scoping
Date Tue, 06 Oct 2009 18:59:31 GMT
Betwixt does not correctly implement namespace scoping

                 Key: BETWIXT-67
             Project: Commons Betwixt
          Issue Type: Bug
            Reporter: Nicholas W.
            Priority: Critical

According to: 

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="">
    <element name="title" property="title" uri=""/>
    <element name="creator" property="creator" uri=""/>
    <element name="publisher" property="publisher" uri=""/>
    <element name="description" property="description" uri=""/>
    <element name="identifier" property="identifier" uri=""/>
    <element name="subject" property="subject" uri=""/>

And with the beanwriter having  extra configuration of the NamespacePrefixMapper like this:

prefixMapper.setPrefix("", "dc");
prefixMapper.setPrefix("", "oai_dc");

The XML generated is like this:

<oai_dc:dc xmlns:oai_dc="">
    <dc:title xmlns:dc="">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>

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.

View raw message