[
https://jira.jboss.org/jira/browse/DNA-223?page=com.atlassian.jira.plugin...
]
Randall Hauch resolved DNA-223.
-------------------------------
Resolution: Done
It is not really possible to correctly handle unqualified attributes in a general manner
if we consider the XML Schema specification. This is because an XML schema by default
will require that unqualified attributes inherit the element's namespace, and because
within any single XML schema it is possible to define one element that requires
unqualified attributes inherit the element's namespace while other element definitions
require that unqualified attributes use the default namespace. In other words, a
general-purpose sequencer cannot always do the "correct" thing without
thoroughly understanding the XML Schema(s) used by an XML document.
Therefore, this has been addressed by changing the XML sequencer to be configurable as to
the desired behavior. Note that this behavior is fixed for a particular document, and
still won't properly handle an XML document that uses a schema with a mixture of
qualified and unqualified attribute forms. The default is to use the default namespace
(at that position in the document), which is really the default for XML documents. To
make it easy to specify a sequencer by classname that inherits the element's namespace
for unqualified attributes, there is also a new InheritingXmlSequencer, which extends
XmlSequencer and simply overrides the default setting.
Still, this issue is considered closed. Any further need to handle both cases within a
single XML document based upon the referenced XML Schema definitions will be handled as a
new feature request (or at least a new issue).
Note that there were some changes/corrections made to some of the Path classes and utility
classes (e.g., MockSequencerOutput, etc.).
Also, the XmlSequencer class was rewritten to properly handle namespaces. First of all,
the old implementation required that the namespaces in the NamespaceRegistry were
registered with the same prefixes. Second, attribute values that were treated as names
were not using the namespaces defined in the document. The new logic follows that used in
XmlHandler in 'dna-graph'. (Note that XmlHandler is not extended because of the
performance hit of the extra adapter between XmlHandler.Destination and SequencerOutput.
The current design is also much simpler to follow, since it is much more direct and
obvious what the sequencer's handler is doing.)
XML sequencer does not properly handle namespaces of unqualified
attributes
---------------------------------------------------------------------------
Key: DNA-223
URL:
https://jira.jboss.org/jira/browse/DNA-223
Project: DNA
Issue Type: Bug
Components: Sequencers
Affects Versions: 0.2
Reporter: Randall Hauch
Assignee: Randall Hauch
Fix For: 0.3
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
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira