Re: default attributes and namespaces

Joseph Kesselman wrote:
> 
> This is an XML processing question more than a DOM question. In brief, DTDs
> do not support namespaces nor vice versa.

It is a DOM question in the sense that DOM has a very vague description of
what default attributes do. Do they come with namespaces or not? Are
both possible? Is it left open to which kind of schema language
you use? I think it should be clarified what is going on.

> DTDs are not namespace-aware. Period. They match on the full qualified
> name. If you're using DTDs to set up your default attributes, a default for
> attribute foo:bar is applied to all attributes with exactly that name, and
> only those attributes, no matter what namespace foo: is bound to.

But the problem is that the DOM doesn't *know* about prefix/namespace
bindings (and scoping rules) at all as far as I can determine.

So does this mean a new attribute is created with the name 'foo:bar'
which is not in any namespace, if no attribute can be found that has
name bar and prefix foo? Or should the DOM know about prefix/namespaceURI
bindings all of a sudden in order to support DTDs?  

And I'm not entirely sure how this argument works now:

  Note also that changing the prefix of an attribute that is known to have
  a default value, does not make a new attribute with the default value and
  the original prefix appear, since the namespaceURI and localName do not
  change.

But you'd say in this case this *should* happen, as there is no namespaceURI
for a DTD-defined default value, and the argument 'since the namespaceURI
and localName do not change' cannot apply, as the default value doesn't
care about namespaces. Or would this attribute node be like it was created
using the old DOM level 1 API?

And what about this?

removeNamedItemNS

  Removes a node specified by local name and namespace URI. A removed
  attribute may be known to have a default value when this map contains
  the attributes attached to an element, as returned by the attributes
  attribute of the Node interface. If so, an attribute immediately appears
  containing the default value as well as the corresponding namespace URI,
  local name, and prefix when applicable.

Presumably DTD defined attributes would then never appear under these
circumstances, then, but only when removeNamedItem? Or would a new
node indeed occur here, but what namespace URI would it have? 
The namespace URI may not be 'applicable' and I'm not sure what it is
corresponding to..

In what I read about DTDs and namespaces it seems to indicate a sort of
textual replacement and the prefix getting the namespace URI from prefix
definition scope. It's okay if the DOM says something else, of course,
but I'd like to figure out *what* it says first.

> If you don't like that answer, find a processor that supports the XML
> Schema language and rewrite your document type description into that format
> rather than using the old DTD syntax. Defaults set in the XML Schema are
> applied on a namespace-aware basis, matching the localname and namespace
> URI rather than the qname.

I'm trying to implement the DOM spec as well as I can, and this seems to
mean also supporting DTDs, right? Or am I to understand that the DOM spec
does not specify what happens with default values that are defined in
DTDs at all? Is 'foo:bar' just taken as a name and is the prefix not
recognized?

Anyway, a small paragraph in the DOM recommendation about these issues
would've helped a lot; right now it seems to assume we'll use a 
namespace aware way to define default attributes.

Regards,

Martijn

Received on Thursday, 8 November 2001 10:04:18 UTC