Loading ...
Sorry, an error occurred while loading the content.

FW: XML: attributes and namespaces - no clear solution

Expand Messages
  • misha.wolf@thomsonreuters.com
    fyi ... From: Grosso, Paul [mailto:pgrosso@ptc.com] Sent: 10 August 2011 17:15 To: xml-editor@w3.org; Wolf, Misha (M Content Mktpl) Cc:
    Message 1 of 1 , Aug 10, 2011
    • 0 Attachment
      fyi

      -----Original Message-----
      From: Grosso, Paul [mailto:pgrosso@...]
      Sent: 10 August 2011 17:15
      To: xml-editor@...; Wolf, Misha (M Content Mktpl)
      Cc: iptc-news-architecture-dev@yahoogroups.com
      Subject: Re: XML: attributes and namespaces - no clear solution


      >
      > From: iptc-news-architecture-dev@yahoogroups.com [mailto:iptc-news-
      > architecture-dev@yahoogroups.com] On Behalf Of Michael Steidl (IPTC)
      > Sent: 27 June 2011 12:10
      > To: iptc-news-architecture-dev@yahoogroups.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:
      >
      > ** [1] is the standard document of the W3C and it speaks about
      Applying
      > Namespaces to Elements and Attributes (chapter 6) :
      > - 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
      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."
      > . . .

      > - 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
      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."
      >
      > 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.
      > . . .

      > Conclusion:
      > - 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

      Summary
      -------
      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.

      Details
      -------
      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.[1]

      The in-scope default namespace declaration applies to unprefixed
      elements.[2] It does not apply to unprefixed attributes.[3][4]

      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


      [1] "...a namespace declaration applies to all element and attribute
      names within its scope whose prefix matches that specified in the
      declaration."

      [2] "A default namespace declaration applies to all unprefixed element
      names within its scope."

      [3] "Default namespace declarations do not apply directly to attribute
      names."

      [4] "The namespace name for an unprefixed attribute name always has no
      value."

      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.
    Your message has been successfully submitted and would be delivered to recipients shortly.