- From: Maciej Stachowiak <mjs@apple.com>
- Date: Thu, 05 Nov 2009 02:18:31 -0800
- To: Julian Reschke <julian.reschke@gmx.de>
- Cc: public-html@w3.org
On Nov 4, 2009, at 1:26 PM, Julian Reschke wrote: > In today's panel it was pointed out that people do not "get" that > the real identifier for an element type is a tuple (namespaceURI, > localName), and thus URI-based extensibility is a problem. > > My experience in other spaces that use URI-based extensibility is > that this problem goes away once you use an API that actually takes > namespaces into account. > > To address the "tuple" problem, a very simple approach is to use the > so-called "Clark" notation (<http://www.jclark.com/xml/xmlns.htm>), > where the tuple (namespaceURI, localName) is simply replaced by the > string > > {namespaceURI}localName > > Note that a string in Clark notation can always be disambiguated > from a string in prefix notation. We took advantage of that in the > JCR 2.0 specification where we overloaded the methods that > previously took prefixed strings to allow Clark notation as well. > > In the Java (!= JS) API world, we also have been successfully using > Java interfaces for these kind of interfaces, exposing both the > components of the tuple plus the Clark notation, and leaving it to > the implementation how to internally represent that. > > In the panel it was also pointed out that no proposals have been > made to actually enhance DOM L2 with respect to this. On the other > hand, it hasn't been exactly clear that the WG actually is > interested to pursue this. If we are (unconference session Thursday > or Friday), we really should spend some time looking into this. I > can't say that I fully understand the restrictions under which we > can extend then DOM (IDL?), but I'm certainly willing to contribute. So you could imagine code like this: var el1 = document.createElementNS2("{http://www.w3.org/1999/ xhtml/}span"); var el2 = document.getElementsByTagNameNS2("{http://www.w3.org/1999/xhtml/ }div")[0]; el2.appendChild(el1); Hmm. The fact that you have a single identifier instead of a tuple sucks less. But it seems to me the resulting code is not very easy to read, or pleasant to write. You could put the bracey bit in a variable like people do with namespace URIs today: var xhtmlNS = "{http://www.w3.org/1999/xhtml/}"; var el1 = document.createElementNS2(xhtmlNS + "span"); var el2 = document.getElementsByTagNameNS2(xhtmlNS + "div")[0]; el2.appendChild(el1); But then all you've really done is replace a comma with a plus. I'm not convinced that this will aid author understanding. Furthermore, what you're writing still doesn't match the markup, which uses prefixes instead of Clark notation. Thus I think content producers and consumers will continue to mistakenly think the qname is the semantic unit, instead of the Clark-style namespace+URI string. Regards, Maciej
Received on Thursday, 5 November 2009 10:19:12 UTC