Re: FPWD Review Request: HTML+RDFa

Mark Birbeck wrote:
> First I'll show a typical JavaScript algorithm for obtaining prefix
> mappings from an element in an RDFa parser, and then we'll look at
> whether that algorithm can be justified from the point of view of the
> RDFa spec.
> 
> Here's some typical code:
> 
>   function getMappingsFromElement(element, mappingList) {
>     var attributes = element.attributes, attrName, i;
> 
>     if (attributes) {
>       for (i = 0; i < attributes.length; i++) {
>         attrName = attributes[i].nodeName;
> 
>         if (attrName.substring(0, 5) === "xmlns") {
>           if (attrName.length === 5) {
>             mappingList.add("", attributes[i].nodeValue);
>           } else if (attrName.substring(5, 6) === ':') {
>             mappingList.add(attrName.substring(6), attributes[i].nodeValue);
>           }
>         }
>       }
>     }

A tangential issue here: http://rdfa.info/wiki/Rdfa-in-html-issues says 
"Shane McCarron says: RDFa is defined in terms of XML Namespaces 1.0. An 
empty xmlns value is an error, and should therefore be ignored by any 
conforming processor." (see also 
http://lists.w3.org/Archives/Public/public-rdf-in-xhtml-tf/2009Jun/0016.html).

So this getMappingsFromElement is buggy (if it's going to be used in a 
non-XML context), since it needs to ignore xmlns:* attributes with empty 
values (which can happily exist in non-XML content).

Given that reasoning, presumably content like <foo xmlns:="..."> should 
be considered an error and ignored too, and shouldn't replace the 
default namespace mapping. And presumably non-NCName prefixes like <foo 
xmlns:0="..."> should also be ignored.

To make these kinds of bugs easy to identify and to avoid, I believe the 
HTML5+RDFa draft really needs to define the prefix mapping extraction 
algorithm in precise detail. Referring to the Namespaces in XML spec is 
insufficient, because it's not clear how Namespaces in XML should be 
applied to non-XML content, so HTML5+RDFa needs to make it clear itself.

-- 
Philip Taylor
pjt47@cam.ac.uk

Received on Friday, 4 September 2009 13:17:43 UTC