Unprefixed attributes (was: Re: <attribute ref="thisNamespace:foo"/> not working?)

Sorry for quoting an old message, but I was just catching up on the list and
this links to a question I was about to ask...

On Wed, Nov 01, 2000 at 08:27:36AM +0000, Henry S. Thompson wrote:
> chuck.han@autodesk.com writes:
> > It seems to me that if the global element <root> is valid
> > (qualified--as ht noted--without a prefix since it implies the
> > default namespace), then by the same token, the global attribute
> > "foo" should also be valid (qualified--this is where ht
> > disagrees--again, without a prefix since it implies the default
> > namespace).
>
> The default NS declaration does not apply to unprefixed attributes [1],
> only to unprefixed elements:
> 
>   "A default namespace is considered to apply to the element where it
>   is declared (if that element has no namespace prefix), and to all
>   elements with no prefix within the content of that element. If the
>   URI reference in a default namespace declaration is empty, then
>   unprefixed elements in the scope of the declaration are not
>   considered to be in any namespace. _Note that default namespaces do_
>   _not apply directly to attributes_. [emphasis added]"

I failed to see why w3c would want to require that all attributes be prefixed.
This seems really counterintuitive, so I read the standard's language more
aggressively with that in mind, and note that "not apply directly" is quite
different from "not apply." Namely, the default namespace does not apply
_directly_ to attributes, but the element provides the namespace for
unprefixed attributes. Thus, if the element uses the default namespace, it's
unprefixed attributes are in the default namespace. (Ack! I'm nit-picking a
standards document's language. Say it isn't so. The only way this could be
worse is if I included my own quote from the standard.)

Appendix A.2 is non-normative, but seems intuitive (as I see it):

  "The Per-Element-Type Partitions: Each type in the All Element Types
   Partition has an associated namespace in which appear the names of the
   unqualified attributes that are provided for that element. This is a
   traditional namespace because the appearance of duplicate attribute names
   on an element is forbidden by XML 1.0. The combination of the attribute
   name with the element's type and namespace name uniquely identifies each
   unqualified attribute.

  "In XML documents conforming to this specification, the names of all
   qualified (prefixed) attributes are assigned to the global attribute
   partition, and the names of all unqualified attributes are assigned to
   the appropriate per-element-type partition."

So it sounds like the attribute names are handled as expected, although they
get labeled as "unqualified," which is a mite odd, but then there's this bit
just before section 6:

   "However, each of the following is legal, the second because the default
    namespace does not apply to attribute names:

    <!-- http://www.w3.org is bound to n1 and is the default -->
    <x xmlns:n1="http://www.w3.org" 
       xmlns="http://www.w3.org" >
      <good a="1"     b="2" />
      <good a="1"     n1:a="2" />
    </x>
   "

and _here_ I start to feel like the standard will go against me, so I looked
at a NS-related mailing list and it appears ([1] and [2] provide a decent
summary) that this was discussed and what I'm saying is basically correct:
unprefixed attributes are actually in the namespace of the given element,
and that example is only an example of parser-decided uniqueness--it should
(probably?) raise an error in the schema processing.

If this is incorrect, maybe someone could make this all a little clearer,
and indicate why the alternative could be desireable?


Much appreciated,
Robert Braddock (an xmlschema-dev subscriber--no CC necessary)

[1] http://lists.w3.org/Archives/Public/xml-names-editor/2000Aug/0012.html
[2] http://lists.w3.org/Archives/Public/xml-names-editor/2000Aug/0014.html

Received on Sunday, 19 November 2000 19:54:18 UTC