Closed Roensby closed 2 years ago
It seems that if I include a reference in the CONSTRUCT query to the type of the value, it validates successfully. I'll close it, since it seems to solve the issue.
Does not validate, because the validator cannot resolve the rdf:type
of Bob:
CONSTRUCT {
<http://example.org/my-event> rdf:type schema:Event .
<http://example.org/my-event> schema:organizer ?organizer .
} WHERE {
?organizer schema:name "Bob" .
}
Does validate, because the validator is given the type of Bob to construct with:
CONSTRUCT {
<http://example.org/my-event> rdf:type schema:Event .
<http://example.org/my-event> schema:organizer ?organizer .
?organizer rdf:type ?organizerType .
} WHERE {
?organizer schema:name "Bob" .
?organizer rdf:type ?organizerType
}
You are right @Roensby in your earlier comment. The fact that you have additional information in your triple store does not mean that this is somehow available to the validator. The validator simply executes a SPARQL CONSTRUCT query to get a graph which should contain all the context information needed to correctly validate against it's shapes. As you correctly point out, in this example the query should also return the type of "Bob", otherwise the validator has no way of knowing about it.
This in fact is more a general point regarding validation with SHACL shapes (and not one specific to the ITB's SHACL validator): you need to always ensure that all context that would be needed, either in the input data or the shapes themselves is either configured in or provided to the validator. Taking foaf as a common example, if you are writing a shape that verifies something is a foaf:Agent and you use it to validate a foaf:Person (a subclass of foaf:Agent), the validator would need to also be configured with the foaf vocabulary to understand that something which is a foaf:Person is also a foaf:Agent (i.e. you would provide the foaf vocabulary via a validator.shaclFile.XYZ config entry either locally or remotely).
I haven't fully wrapped my head around the SHACL validator yet, so this may just be a simple misunderstanding of what it can do.
Let's say that I load a triplestore with the schema.org models.
I then create a
schema:Person
, sayThen I create a simple SHACL shape for
schema:Event
that restricts theschema:organizer
to aschema:Person
:I have hooked up the SHACL validator to the triplestore and I now use the SHACL query validation tool with a CONSTRUCT query to validate a
schema:Event
, referencing Bob as organizer:I would expect this to pass validation, since the triplestore has Bob stored as a
schema:Person
. However, it fails:Am I expecting too much in terms of the SHACL validator resolving
<http://example.org/bob>
and discovering itsrdf:type
via the connection to the triplestore?In any case, thank you for your work!