Consider the following:
{
"x:p": {
"@value": "foo",
"@type": "http://www.w3.org/1999/02/22-rdf-syntax-ns#langString"
}
}
It is currently a valid JSON-LD document, even though it corresponds to an invalid RDF graph (because a literal with datatype rdf:langString but no language tag is not allowed in the abstract data model.
In fact, this causes an ambiguity in the toRdf algorithm, which does not tell you what to do with this pathological case, and implementations diverge.
- jsonld.js simply "eats" the datatype, turning it implicitly into (permalink)
- sophia faithfully produces
"foo"^^rdf:langString (permalink), but then refuses to parse the resulting n-quads (permalink)
- PyLD raises an error
Proposed solution: we should refine the definition of value object to forbid @type to have value http://www.w3.org/1999/02/22-rdf-syntax-ns#langString (and, eventually, http://www.w3.org/1999/02/22-rdf-syntax-ns#dirLangString).
Accordingly, the Expand algorithm should raise an "invalid value object" error when it is lead to create such an object (e.g. via IRI expansion and/or type coercion).
Consider the following:
{ "x:p": { "@value": "foo", "@type": "http://www.w3.org/1999/02/22-rdf-syntax-ns#langString" } }It is currently a valid JSON-LD document, even though it corresponds to an invalid RDF graph (because a literal with datatype
rdf:langStringbut no language tag is not allowed in the abstract data model.In fact, this causes an ambiguity in the
toRdfalgorithm, which does not tell you what to do with this pathological case, and implementations diverge."foo"^^rdf:langString(permalink), but then refuses to parse the resulting n-quads (permalink)Proposed solution: we should refine the definition of value object to forbid
@typeto have valuehttp://www.w3.org/1999/02/22-rdf-syntax-ns#langString(and, eventually,http://www.w3.org/1999/02/22-rdf-syntax-ns#dirLangString).Accordingly, the Expand algorithm should raise an "invalid value object" error when it is lead to create such an object (e.g. via IRI expansion and/or type coercion).