Uploaded image for project: 'ModeShape'
  1. ModeShape
  2. MODE-231

XML sequencer does not properly handle namespaces of unqualified attributes

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 0.3
    • 0.2
    • Sequencers
    • None
    • Workaround Exists
    • Hide

      No workaround is needed for the XML sequencer in 0.3, as long as there is not a mixture of inherited and default namespace behavior in a single document. (There is no workaround for that.) For the XML sequencer in 0.2, the workaround for some XML documents is to simply put a prefix on every element and attribute (or, not having any prefixes on any element or attribute) works.

      Show
      No workaround is needed for the XML sequencer in 0.3, as long as there is not a mixture of inherited and default namespace behavior in a single document. (There is no workaround for that.) For the XML sequencer in 0.2, the workaround for some XML documents is to simply put a prefix on every element and attribute (or, not having any prefixes on any element or attribute) works.
    • High

      I've been looking at the XML sequencer behavior, and I was a little surprised to find out that it treats unqualified attributes (i.e., those without a namespace prefix) as inheriting the namespace of the parent element. For example, this XML document:

      <dna:system xmlns:dna="http://www.jboss.org/dna" xmlns:jcr="http://www.jcp.org/jcr/1.0">
      <!-- Define the sources from which content is made available -->
      <dna:sources>
      <sourceA name="Cars" dna:classname="org.jboss.dna.connector.inmemory.InMemoryRepositorySource" retryLimit="3" />
      <sourceB name="Aircraft" dna:classname="org.jboss.dna.connector.inmemory.InMemoryRepositorySource" />
      </dna:sources>
      </dna:system>

      is imported so that the "retryLimit" attribute is turned into a "dna:retryLimit" property. That property, however, should use the default namespace.

      I'm not sure whether this was intended, but I don't believe this behavior is correct. Yes, unqualified child elements do inherit the namespace of their parent, but attributes do not. According to the spec (http://www.w3.org/TR/xml-names/#defaulting), emphasis mine:

      "The scope of a default namespace declaration 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 default namespace declarations. In the case of an empty tag, the scope is the tag itself.
      "A default namespace declaration applies to all unprefixed element names within its scope. Default namespace declarations do not apply directly to attribute names; the interpretation of unprefixed attributes is determined by the element on which they appear.
      "If there is a default namespace declaration in scope, the expanded name corresponding to an unprefixed element name has the URI of the default namespace as its namespace name. If there is no default namespace declaration in scope, the namespace name has no value. The namespace name for an unprefixed attribute name always has no value. In all cases, the local name is local part (which is of course the same as the unprefixed name itself)."

      Unfortunately, none of the examples in the spec seem to show the behavior for attributes. But here are a few links that seem to agree with my interpretation:
      http://www.twoscomplement.com/2008/03/16/xml-attribute-namespaces/
      http://annevankesteren.nl/2005/03/null-namespace

            rhauch Randall Hauch (Inactive)
            rhauch Randall Hauch (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: