Re: ISSUE-41/ACTION-97 decentralized-extensibility

On Oct 1, 2009, at 1:00 PM, Julian Reschke wrote:

> Maciej Stachowiak wrote:
>> ...
>> You said it's well-defined how to find out what meaning an element  
>> has using DOM Level 1 (presumably determining the namespaceURI  
>> somehow). Can you state or point to the definition?
>> ...
>
> 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.

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>

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.

Thus, your algorithm for finding the namespace URI of an element using  
DOM Level 1 APIs may be well-defined but it is incorrect.

Regards,
Maciej

Received on Thursday, 1 October 2009 21:04:55 UTC