Shapes Constraint Language (SHACL)  is a World Wide Web Consortium (W3C) specification for validating graph-based data against a set of conditions. Among others, SHACL includes features to express conditions that constrain the number of values that a property may have, the type of such values, numeric ranges, string matching patterns, and logical combinations of such constraints. SHACL also includes an extension mechanism to express more complex conditions in languages such as SPARQL.
|Status||Published W3C Recommendation (20 July 2017)|
|Editors||Holger Knublauch, Dimitris Kontokostas|
|Base standards||RDF, SPARQL|
|Related standards||RDFS, OWL|
A SHACL validation engine takes as input a data graph and a graph containing shapes declarations and produces a validation report that can be consumed by tools. All these graphs can be represented in any Resource Description Framework (RDF) serialization formats including JSON-LD or Turtle. The adoption of SHACL may influence the future of linked data.
World Wide Web Consortium published the following SHACL Specifications:
- SHACL (W3C Technical Recommendation) is the main document, defining the features of SHACL Core and its extension mechanism called SHACL-SPARQL. SHACL Core defines the basic syntax and structure of shapes, constraints, the built-in kinds of constraints, and how to link shapes to data nodes. SHACL-SPARQL defines how to express constraints that are not covered by the built-in constraint kinds.
- SHACL Advanced Features (W3C Working Group Note), the most recent version of which is maintained by the SHACL Community Group defines support for SHACL Rules, a powerful feature (inspired by SPIN rules) for data transformations, inferences and mappings based on data shapes. Also includes extensions of SHACL-SPARQL such as user-defined functions.
- SHACL Compact Syntax (SHACL Community Group Report).
Further Reading and Commercial ToolsEdit
Open Source ToolsEdit
The SHACL Test Suite and Implementation Report linked to from the SHACL W3C specification lists some open source tools that could be used for SHACL validation as of June 2019. By the end of 2019 many commercial RDF database and framework vendors announced support for at least SHACL Core.
Some of the open source tools listed in the report are:
- dotNetRDF - a .NET Framework online service
- pySHACL - an open source SHACL validator library for command line use written in Python
- shaclex - a Scala implementation of both SHACL and ShEx
- TopBraid SHACL API - an open source implementation of SHACL Validation by TopQuadrant, based on Apache Jena. The same code is used in the TopBraid commercial products. However, commercial products also support SHACL Advanced Features.
Eclipse rdf4j is an open source Java framework for processing RDF data. It now supports SHACL validation.