Re: XML Literals poll

FWIW, my own thoughts on the use of XML literals.

> Below are six questions on XML literals. Please help the WG get a feeling for the general opinion within the group by answering the questions. Answers in the usual +1/±0/-1 style are appropriate.
> 
> Thanks,
> Richard
> 
> 
> 
> Q1. Should the specs define a way to compare XML literals based on value?
> 
> In other words, in the same way that integers 7 and 007 have the same value, should <foo/> and <foo></foo> be defined as having the same value?

-1. The only interesting use of XML literals now, from my perspective, is capturing HTML markup in RDFa. Given that RDFa may be used with non-closing tags (i.e., not a valid XML infoset), this can't work reliably. To do so, you'd need to know if the content model was HTML or XML. This could potentially be addressed by introducing a new rdf:HTMLLiteral, but that seems a step in the wrong direction.

> Q2. Should the specs say that RDF implementations MUST support value-based comparison?
> 
> In other words, assuming the specs define a value space that answers Q1 in the affirmative, is it required that all RDF toolkits implement some sort of canonicalization somewhere in the process?

-1. See #1 for reasoning.

> Q3. Should the *lexical* space be in canonical form?
> 
> In other words, should
>   <> ex:value "<foo/>"^^rdf:XMLLiteral.
>   <> ex:value "<foo></foo>"^^rdf:XMLLiteral.
> 
> result in a graph with one triple (canonicalize) or two (don't canonicalize)? Note that if you answer “two”, then it is unavoidable that round-tripping an XML literal, or storing the same XML literal in two different formats (say, RDF/XML and Turtle) and reading it again, will sometimes result in a different triple (with the same value though).

-1

> Q4. Should *invalid XML* be allowed in the lexical space?
> 
> In other words, should "</bar !!!>"^^rdf:XMLLiteral be ill-typed (just like "AAA"^^xsd:integer) or well-typed (just like "</bar !!!>"^^xsd:string)?

+1. If we depend on authors only using "correct" markup, we'll invalidate many common cases, even where the HTML is incorrect. rdf:XMLLiteral should simply be a sub-datatype of xsd:string. RDFa uses rdf:XMLLiteral to trigger using innerHTML rather than innerText when extracting literal content.

> Q5. Should the specs say that RDF/XML parsers MUST canonicalize when handling parseType="literal"?
> 
> RDF/XML parsers are often implemented on top of an XML parser, and hence they don't have access to a low-level representation of the XML literal, e.g., did it use single or double quotes in the attributes, what order where the attributes in, or how many spaces were between them? If they don't canonicalize, then two different RDF/XML parsers would be pretty much guaranteed to parse the same RDF/XML file into different triples (or even different runs of the same parser over the same file could yield different triples).

-1. C14N is a pain. I'd remove any requirement that in-scope namespace definitions be added to top-level elements within the nodeset too. I do think there's value in maintaining the in-scope @lang or @xml:lang as part of the literal, though.

> Q6. Should it be required that producers of XML literals in concrete syntaxes (Turtle, N-Triples, other parseTypes in RDF/XML) canonicalize the literals themselves?
> 
> If the lexical space is canonicalized (see Q3), then it means that canonicalization either has to be done by parsers (see Q5), or by content producers.

-1

> (FWIW, the RDF 2004 design is: Q1: Yes. Q2: Yes. Q3: Yes. Q4: No. Q5: Yes. Q6: Yes.)

As an implementer I'm painfully aware of this!

Gregg Kellogg

Received on Tuesday, 22 November 2011 17:49:04 UTC