Closed k00ni closed 3 years ago
On the RDF side the difference is a literal without a lang tag is always different from one having a lang tag while lack of datatype means the datatype is assumed to be xsd:string
(so "foo"
and "foo"^^http://www.w3.org/2001/XMLSchema#string
are equal; see https://www.w3.org/TR/rdf11-concepts/#section-Graph-Literal for a reference).
This creates an ambiguity because xsd:string
datatype has two valid representations - lack of a datatype (in PHP context we would say null
) and explicit xsd:string
. To deal with this ambiguity I decided to explicitly forbid the null
representation (but I also admit it should be precisely described in the method comment).
I must also admit this convention is not followed by Literal
class constructor and DataFactory::literal()
method. What is worse, DataFactory::literal()
has different default (null
) than the Literal
class constructor (xsd:string
). It's clear it must be synced.
I see three options to make it in sync:
null
and xsd:string
datatype)DataFactory::literal()
and Literal
class constructor for the sake of user convenience (just set the default consistently to xsd:string
) but (also for sake of user convenience) ban null in the Literal:getDatatype()
method and explain in the comment the method should return xsd:string
(of course as a full URL) both when xsd:string
datatype is explicit and implicit.Personally I'm the most in favor of the last one and I dislike the first one the most. And what do you think?
By the way to make such assumptions clear and easy to verify (and to save copy-pasting of tests code in implementations) I started to build a tests suite for the rdfInterface compatibility in the tests directory. The simpleRdf already makes use of them.
I am working on my in-memory store implementation currently, which might be a good practice range for rdfInterface. When taking the view as an outsider, some things are not clear enough (yet), like how to use certain things or what you have to provide sometimes.
I follow your arguments here and support the third option too. Let us continue shaping the library with external projects and make it viable and fun to use. Might worth some iterations, but we are on a good way IMHO.
When taking the view as an outsider, some things are not clear enough (yet), like how to use certain things or what you have to provide sometimes.
Sure thing. I didn't put much effort into documenting things so far as I would say it's still in quite early development stage. Please don't hesitate to ask when you run into such issues. They may indicate lack of documentation but also design flaws and it's important to discuss them.
As for now my plan is to:
QuadTemplate
.Only once this is done and I have a feeling rdfInterface works well focus on documenting it well.
First two point of the list above are likely to be ready until the end of March. Can't tell about the others.
I follow your arguments here and support the third option too. Let us continue shaping the library with external projects and make it viable and fun to use. Might worth some iterations, but we are on a good way IMHO.
Ok, I will make the adjustments.
By the way, I just read https://www.w3.org/TR/rdf11-concepts/#section-Graph-Literal carefully and there will be a change in the expected Literal::getDatatype()
behavior:
http://www.w3.org/1999/02/22-rdf-syntax-ns#langString
should be returnedhttp://www.w3.org/2001/XMLSchema#string
should be returnedGood hint!
Literal
interface sayshttps://github.com/sweetrdf/rdfInterface/blob/48d8a66bb7952e30e7382dd2a57cb3ce8cccebeb/src/rdfInterface/Literal.php#L45-L47
Does it mean that there is a default value for
getDatatype
? Like an empty string?IMHO regarding the PHP side there is no difference between
getDatatype
andgetLang()
, both might benull
at the beginning. But their definition differs for some reason. Can you please explain why?