- From: Steve Harris <steve.harris@garlik.com>
- Date: Thu, 17 May 2012 18:54:05 +0100
- To: Ivan Herman <ivan@w3.org>
- Cc: Richard Cyganiak <richard@cyganiak.de>, Guus Schreiber <guus.schreiber@vu.nl>, RDF WG <public-rdf-wg@w3.org>
On 2012-05-17, at 17:32, Ivan Herman wrote: > > On May 17, 2012, at 17:48 , Steve Harris wrote: > >> >> I (occasionally) have to explain out tech stack to new developers coming in, it's not getting any easier. >> >> I can imagine struggling to explain why: >> >> <x> <p> '''<p class="foo" id="bar">baz'''^^xsd:HTMLLiteral . >> <y> <p> "<p id='bar' class='foo'>baz</p>"^^xsd:HTMLLiteral . >> >> SELECT * >> WHERE { >> ?s <p> ?o . >> FILTER(?o = "<p id='bar' class='foo'>baz</p>"^^xsd:HTMLLiteral) >> } >> >> returned two results. >> > > What would your developer expect with > > <x> <p> '''0123'''^^xsd:integer . > <x> <p> "123"^^xsd:integer . > > SELECT * WHERE { ?s <p> ?o . FILTER( ?o = "123"^^xsd:integer ) } > > I would certainly expect two results, because I typed the literal. I would actually be surprised if the HTML version did not returned two results! Well, that very much depends on the language. In C-like languages 0123 == 123 is false of course. 123.0 is a different matter, I think the majority of programmers would expect 123 == 123.0 to be true. So, it obviously depends on how you view "<p id='bar' class='foo'>baz</p>"^^xsd:HTMLLiteral, and HTML fragments in general. http://stackoverflow.com/questions/3760991/are-there-any-tools-that-can-compare-html-documents-by-dom-structure suggests that even in javascript it's not common, or expected. I can't think of many languages I'm familiar with where comparing the two DOM structures you'd get from parsing those two strings would return true, using the built in =. You have to call a method to serialise it to a normalised string, and compare the strings. None of this suggests that SPARQL/RDF shouldn't go it's own way and do implicit normalisation, but there should be a reason to do it, to counteract the surprise factor. - Steve -- Steve Harris, CTO Garlik, a part of Experian 1-3 Halford Road, Richmond, TW10 6AW, UK +44 20 8439 8203 http://www.garlik.com/ Registered in England and Wales 653331 VAT # 887 1335 93 Registered office: Landmark House, Experian Way, Nottingham, Notts, NG80 1ZZ
Received on Thursday, 17 May 2012 17:54:38 UTC