- From: Julian Reschke <julian.reschke@gmx.de>
- Date: Thu, 01 Oct 2009 23:46:53 +0200
- To: Maciej Stachowiak <mjs@apple.com>
- CC: Anne van Kesteren <annevk@opera.com>, Jonas Sicking <jonas@sicking.cc>, Adrian Bateman <adrianba@microsoft.com>, HTML WG <public-html@w3.org>, Tony Ross <tross@microsoft.com>, Sam Ruby <rubys@intertwingly.net>
Maciej Stachowiak wrote: >> I'm referring to the algorithm that ways mentioned multiple times in >> RDFa threads: visit all parents, and check for all attributes where >> the local name is "xmlns", or starts with "xmlns:". Figure out >> namespace declarations from those. > > That algorithm is incorrect. Prefix bindings apply at parse time, not > lookup time. Really? Pointer, please? Personally, I really don't care. I'm interested in processing content as sent over the wire (you know, documents, not web applications), where scripts never execute. > Here's a test case, using XML. What's the namespace of the <bar> element? > > <foo xmlns:bar="http://example.com/bar"> > <baz id="baz" /> > <xhtml:script xmlns:xhtml="http://www.w3.org/1999/xhtml/"> > var newElement = document.createElement("bar:bar", > "http://barbar.com/barbar/"); > document.getElemebtById("baz").appendChild(newElement); > </xhtml:script> > </foo> It depends on which API you use. I'll be happy to answer this for a *document*, not a DOM tree after script execution. > Your algorithm says "http://example.com/bar" but the correct answer is > "http://barbar.com/barbar/". This is not just "an edge case" - it will > apply any time the DOM has been mutated after parsing. It affects not > just element or attribute creation, but also moving chunks of the DOM > from one place to another with different namespace declarations in scope > (the namespace URIs shouldn't change for the moved content!) or to > adding or removing namespace declaration attributes. Yes, that's a problem when you're stuck with a non-namespace aware API. The best way to fix this is to make sure that UAs all implement namespace-aware APIs, and that they behave the same for XML and HTML content. I believe that's something this WG should do, instead of claiming that compatibility with broken web content prevents us from doing that. > Thus, your algorithm for finding the namespace URI of an element using > DOM Level 1 APIs may be well-defined but it is incorrect. See above. BR, Julian
Received on Thursday, 1 October 2009 21:47:34 UTC