Value does not have datatype error with sh:datatype xsd:anyURI
Abrom8 opened this issue · 3 comments
Properties with sh:datatype xsd:anyURI
always produce Value does not have datatype <http://www.w3.org/2001/XMLSchema#anyURI>
error.
I created a minimal example for the https://shacl-playground.zazuko.com/ playground.
Shapes Graph:
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix g-validation: <http://localhost:3001/shapes/validation#> .
@prefix g-framework: <http://localhost:3001/shapes/g-framework#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
g-validation:ServiceShape
a sh:NodeShape ;
sh:targetClass g-framework:Service ;
sh:property [ sh:path g-framework:content ;
sh:datatype xsd:anyURI ] ;
.
Data Graph:
{
"@context": {
"g-framework": "http://localhost:3001/shapes/g-framework#",
"g-validation": "http://localhost:3001/shapes/validation#",
"sh": "http://www.w3.org/ns/shacl#",
"xsd": "http://www.w3.org/2001/XMLSchema#"
},
"@type": "g-framework:Service",
"g-framework:content": "http://example.org/"
}
Thank you for reporting.
In your case, the error is in fact correct because the value is a plain literal. The validation sh:datatype
is strict in that it requires a literal to have an exact matching datatype. Compare with other SHACL implementations, all of which yield same result.
If you need your JSON-LD to keep its idiomatic form, you can modify the @context
to have it assert the values of the content
property:
{
"@context": {
"g-framework": "http://localhost:3001/shapes/g-framework#",
"g-validation": "http://localhost:3001/shapes/validation#",
"sh": "http://www.w3.org/ns/shacl#",
- "xsd": "http://www.w3.org/2001/XMLSchema#"
+ "xsd": "http://www.w3.org/2001/XMLSchema#",
+ "g-framework:content": {
+ "@type": "xsd:anyURI"
+ }
},
"@type": "g-framework:Service",
"g-framework:content": "http://example.org/"
}
On a related note, the actual URI is not actually validated for correctness. One might argue that it should (we do that for numeric values and dates) but none of the other implementations available on https://rdfshape.weso.es/shaclValidate do that either...
Thank you! The example with the @context
helped a lot! 👏