FW: XML: attributes and namespaces - no clear solution
From: Grosso, Paul [mailto:pgrosso@...]
Sent: 10 August 2011 17:15
To: xml-editor@...; Wolf, Misha (M Content Mktpl)
Subject: Re: XML: attributes and namespaces - no clear solution
> From: email@example.com [mailto:iptc-news-
> firstname.lastname@example.org] On Behalf Of Michael Steidl (IPTC)
> Sent: 27 June 2011 12:10
> To: email@example.com
> Subject: XML: attributes and namespaces - no clear solution
> This posting refers to the discussion on the NAR-dev conference call
> last Friday, 24 June. The issue was: do attributes inherit the
> namespace of its element and this way also default namespaces?
> After some searching my findings are:
> **  is the standard document of the W3C and it speaks about
> Namespaces to Elements and Attributes (chapter 6) :is
> - 6.1 Namespace 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
> the tag itself.names
> Such a namespace declaration applies to all element and attribute
> within its scope whose prefix matches that specified in thenames
> . . .
> - 6.2 Namespace defaulting
> "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
> within its scope. Default namespace declarations do not apply directlySummary
> to attribute names; the interpretation of unprefixed attributes is
> determined by the element on which they appear."
> This leaves open what "determined by the element" exactly means - what
> we discussed last Friday: does the attribute inherit the element's
> namespace - or not.
> The next paragraph tells:
> " .... The namespace name for an unprefixed attribute name always has
> no value. ..."
> ... hm, this does not explain what "determined by the element" exactly
> means (Btw: the Errata document for this document says no errata exist
> ...). And there is no note available for the example above explaining
> if the @href pertains to the html: namespace or not.
> . . .
> - W3C does not define how default namespaces apply to attributes in a
> straightforward way
> - It is not fully clear if an attribute of a namespaced element
> interits its namespace.
> - Published views on that matter lean towards "does not inherit" - but
> not unambiguously
Attributes do not inherit namespaces. Unprefixed attributes are not
in any namespace (in the W3C/XML sense of namespace). Therefore,
attributes never inherit the default namespace.
Namespaces are never inherited. The word "inherit" does not appear
in the namespace specification. Namespace *declarations*--which
associate a namespace prefix with a namespace name (URI)--are scoped
by the element on which they occur. The in-scope namespace declaration
at the point of any *prefixed* element or attribute determines the
namespace of that prefixed element or attribute.
The in-scope default namespace declaration applies to unprefixed
elements. It does not apply to unprefixed attributes.
All this seems quite clear from the specification (which is over
twelve years old and hasn't seemed to cause major confusion for
most of that time). Apparently, the wording "the interpretation
of unprefixed attributes is determined by the element on which
they appear" (which was added to the June 2006 Second Edition of
the spec) is the cause of some current confusion. In retrospect,
I can see how adding that wording was perhaps not the best choice.
If it helps, ignore it, as it wasn't in the original version.
What that wording was trying to say is that the semantics in an
application sense--not in an XML parsing sense--of an unprefixed
attribute may be determined by the element on which it occurs.
For example, name="foo" attribute on an HTML <a> element means
something different from name="foo" on an HTML <param> element.
The unprefixed "name" attribute on the <a> element is semantically
not (necessarily) related to the unprefixed "name" attribute on
the <param> element. Given that the namespace specification doesn't
discuss application semantics anywhere else, perhaps it would have
been better not to have added this phrase. In any case, nothing
in this statement has anything to do with namespace interpretation.
Paul Grosso (co-chair) for the XML Core Working Group
 "...a namespace declaration applies to all element and attribute
names within its scope whose prefix matches that specified in the
 "A default namespace declaration applies to all unprefixed element
names within its scope."
 "Default namespace declarations do not apply directly to attribute
 "The namespace name for an unprefixed attribute name always has no
This email was sent to you by Thomson Reuters, the global news and information company. Any views expressed in this message are those of the individual sender, except where the sender specifically states them to be the views of Thomson Reuters.