Ehsan
Ehsan

Reputation: 581

SHACL Validation Error for External Resources

I have a SHACL schema that is written to validate research variables.

{
  "@id": "m:VariableShape",
  "@type": "sh:NodeShape",
  "targetClass": "pplan:Variable",
  "property": [ 
    {
      "path": "m:dataType",
      "class" : "rdfs:Datatype",
      "minCount":"1"
    }, 
    {
      "path": "m:varName",
      "datatype": "xsd:string",
      "minCount":"1"
    }
  ]
},    
{
  "@id" : "m:dataType",
  "@type" : "owl:ObjectProperty"
},    
{
  "@id": "m:varName",
  "@type": "owl:DatatypeProperty"
}

And I am trying to validate the following data against it:

{
    "@id" : "ex:bp_var",
    "@type" : "pplan:Variable",
    "m:dataType" : "xsd:decimal",
    "m:varName" : "blood_pressure"
}

The validation of this data against the schema returns a violation report similar to:

a sh:ValidationResult ;
sh:resultSeverity sh:Violation ;
…
sh:value xsd:decimal ;
sh:resultPath <http://.../m#dataType> ;
sh:resultMessage "Value does not have class rdfs:Datatype" ;

Should I be specifying explicitly 'xsd:decimal is of type rdfs:Datatype' to be able to successfully validate my data?

Upvotes: 2

Views: 165

Answers (1)

Stanislav Kralin
Stanislav Kralin

Reputation: 11479

From 1.5 Relationship between SHACL and RDFS inferencing:

SHACL uses the RDF and RDFS vocabularies, but full RDFS inferencing is not required. However, SHACL processors MAY operate on RDF graphs that include entailments [sparql11-entailment] – either pre-computed before being submitted to a SHACL processor or performed on the fly as part of SHACL processing (without modifying either data graph or shapes graph). To support processing of entailments, SHACL includes the property sh:entailment to indicate what inferencing is required by a given shapes graph.

The values of the property sh:entailment are IRIs. Common values for this property are covered by [sparql11-entailment].

Thus, just add the following triple (in the Turtle syntax):

m:VariableShape  sh:entailment  <http://www.w3.org/ns/entailment/RDFS>

Indeed,

When using RDFS semantics, the referents of all recognized datatype IRIs can be considered to be in the class rdfs:Datatype.

This works for me in TopBraid Composer.

Upvotes: 2

Related Questions