RE: [xsl] Attributes with default namespaces? XSLT Rec question..

Subject: RE: [xsl] Attributes with default namespaces? XSLT Rec question..
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Fri, 14 Nov 2008 09:56:46 -0000
> It isn't very explicit about why the default namespace does 
> not apply to attributes, though. And indeed REC-xml-names 
> itself neither.
> Is there anyone on this list who happens to know what the 
> real reasons where why that rule was added to that 
> recommendation? Not that I object, it saves typing a lot of 
> prefixes on occasion. I am just being curious. :-)

It can be hard to work out why a WG has made a decision even when you were
at the meeting. There was a lot of debate about this: I think the three
options were that unprefixed attributes should be (a) in no namespace, (b)
in the default namespace, or (c) in the namespace of the containing element.
The underlying principle is that most attributes are defined as part of the
same vocabulary as the containing element (a "vocabulary" being a unit of
design and change control). You don't want (b) because that means if you
give the element a prefix you have to give most of its attributes a prefix
too (<html:table html:width="10" html:height="30"/> gets pretty ugly). The
choice between (a) and (c) is more arbitrary, but (a) reflects that the
definition and semantics of the attribute are usually local to the element;
the fact that a height attribute is defined for an html:table element
doesn't mean you can use it (in the form html:height) on an invoice element.

This also explains the idea that "no-namespace" names are not in a namespace
- the thinking is that a namespace has a definition, it is controlled by a
design authority, whereas the no-namespace is a bucket in which anyone can
put anything. While this idea has merit, the language of a lot of
specifications would be simpler if the "no-namespace" were treated as just
another namespace that happens to have no name (or a name of "").

Michael Kay

Current Thread