W3C home > Mailing lists > Public > www-dom@w3.org > October to December 2000

Re: question regarding Element.getAttributeNS()

From: Garret Wilson <garret@globalmentor.com>
Date: Fri, 22 Dec 2000 07:54:46 -0800
Message-ID: <007901c06c2f$82a6b500$7245a640@pacbell.net>
To: "Philippe Le Hegaret" <plh@w3.org>
Cc: "www-dom list" <www-dom@w3.org>
Philippe,

> > This worries me a bit regarding how one would use the DOM Level 2 in
> > practice. Let's say I have the following document:
> >
> > <myDocument xmlns="www.me.com" xmlns:myNS="www.me.com" >
> >   <myElement myAttr="1"/>
> >   <myElement myNS:myAttr="1"/>
> > </myDocument>
> >
> > Using the DOM Level 2, how can I elegantly get the value of the
myElement
> > "a" attribute?
>
> Well, given that your document is inelegant, DOM Level 2 will not
facilitate
> your life. Your two attributes are differents since there are not in the
same
> namespace. In practice, you'd better use only one form in your document.

Perhaps, but I'm talking about documents created by other people (which
probably include some inelegant documents ;) ). While you're correct that
the two attributes are in different namespaces, it seems to me that they
still refer to the same attribute in a particular schema.

> I would not recommend a such design in the
> same namespace. The returned attr will not have the same semantic
depending
> on if it has a namespace or or.

No? Let me give a useful example:

<html xmlns=".../w3/xhtml/..." xmlns:xhtml=".../w3/xhtml/...">
...
<img src="image1.jpg" />
<img xhtml:src="image2.jpg" />

This document, while a bit silly, is as far as I can tell a completely valid
XHTML document (ignoring the missing pieces). Both <img> src and <img>
xhtml:src refer to the same attribute in the schema, right? (This, I
suppose, is my big assumption.)

If one wants to correctly interpret all XHTML documents, then, one must
search both for <img> src and <img> xhtml:src, even though they are in
different namespaces, because someone *can* create such a document and it
will be correct. (XHTML is just an example -- this applies to any schema, I
would think.)

Garret
Received on Friday, 22 December 2000 11:38:46 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 22 June 2012 06:13:48 GMT