Eclipse RDF4J SHACL Extensions (RSX) extends SHACL [[shacl]] with useful features implemented by Eclipse RDF4J.

This document uses the prefix rsx which represents the namespace http://rdf4j.org/shacl-extensions# which is accessible via its URL http://rdf4j.org/shacl-extensions. The vocabulary is available in Turtle.

Motivation and Design Goals

RSX aims to extend SHACL [[shacl]] to provide missing features that are useful for the Eclipse RDF4J user base. Eclipse RDF4J aims to implement all these features as a reference implementation.

Eclipse RDF4J promotes RSX as a general extension to SHACL and welcomes other implementers to use the RSX features. Eclipse RDF4J strives to work with the SHACL community to design features that could eventually make it into the next version of SHACL.

Targets

Shape-based Targets

A shape-based target is a shape that is the object of a triple that has rsx:targetShape as its predicate. Conversely, the values of rsx:targetShape are shapes.
TEXTUAL DEFINITION
If triple S rsx:targetShape TS is in the shapes graph then the target nodes of S are all nodes in the data graph that conform to TS.

The remainder of this section is informative.

Shape-based Targets is a powerful way of selecting targets. The use of a shape to select the targets for another shape is a natural extension where the familiar SHACL language that describes constraints can also be used to describe the targets for those constraints.

SPARQL-based Targets are more expressive compared to Shape-based Targets but require using the SPARQL language and semantics for expressing the target selection, rather than SHACL. This also makes them harder to optimize.

Examples

Norwegians must have exactly one norwegianID
ex:NorwegianShape a sh:NodeShape;
  rsx:targetShape [sh:path ex:nationality; sh:hasValue ex:Norwegian];
  sh:property [sh:path ex:norwegianID; sh:minCount 1; sh:maxCount 1];
.
    
ex:OlaNordmann ex:nationality ex:Norwegian;
  ex:norwegianID "12345010150", "54321010150".

ex:KariNordmann ex:nationality ex:Norwegian;
  ex:norwegianID "23413051243".

ex:NoraNordmann ex:norwegianID "12413051143", "57294051143".
    
Instances in namespace "company" must have appropriate class and dc:type
ex:CompanyShape a sh:NodeShape;
  rsx:targetShape [
    sh:nodeKind sh:IRI;
    sh:pattern "^https://company-graph.example.com/resource/company/";
  ];
  sh:class ex:Company;
  sh:property [sh:path dc:type; sh:in ("conglomerate" "collective" "enterprise")];
.
    
<https://company-graph.example.com/resource/company/BigCo> a ex:Organisation.

<https://company-graph.example.com/resource/company/SmallCo> a ex:Company;
  dc:type "enterprise".
    
All langStrings must have one of a predefind set of languages
ex:langStringShape a sh:NodeShape;
  rsx:targetShape [sh:datatype rdf:langString];
  sh:languageIn ("en" "bg");
.
    
ex:EiffelTower rdfs:label "Eiffeltårnet"@no-nb, "Eiffel Tower", "Айфелова кула"@bg.
    
Steve is very popular, so everyone who knows at least three people must know Steve
ex:Personshape a sh:NodeShape;
  rsx:targetShape [sh:path foaf:knows; sh:minCount 3; sh:class foaf:Person];
  sh:property [sh:path foaf:knows; sh:hasValue ex:Steve];
.
    
ex:Mary a foaf:Person;
  foaf:knows [], [], [].

ex:Katie a foaf:Person.

ex:Steve a foaf:Person.
  foaf:knows ex:Mary, ex:Katie, ex:Peter.

ex:Peter foaf:knows ex:Mary, ex:Katie, ex:Peter, ex:Steve.
    
Parties (defined as foaf:Organization with appropriate dc:type) must stick to one of two politics
ex:PartyShape a sh:NodeShape;
  rsx:targetShape [a sh:NodeShape;
    sh:property [sh:path rdf:type; sh:hasValue foaf:Organization];
    sh:property [sh:path dc:type;  sh:hasValue "political-party"];
  ];
  sh:property [sh:path ex:politics; sh:in ("Democrat" "Republican"); sh:minCount 1; sh:maxCount 1];
    
ex:Independent a foaf:Organization;
  dc:type "political-party";
  ex:politics "Socialism".
    

Validation and Graphs

Validation Result Data Graph

Validation results may include the data graph(s) that were considered when producing the validation result.

Validation Result Shapes Graph

Validation results may include the shape graph(s) where the given sh:sourceShape was retrieved from.