- From: Garret Wilson <garret@globalmentor.com>
- Date: Fri, 22 Dec 2000 07:54:46 -0800
- 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 UTC