SHACL editor from Excel

You would like to edit SHACL, but you are wondering how to get started ? Start from Excel.

How-to edit SHACL specifications from Excel files

Download the template file

Start by downloading the template file here

Fill-in the spreadsheet

The file has the following structure:

  • In tab "prefix", declare the necessary prefixes:
    Prefixes tab of the SHACL Excel template

  • In tab "NodeShapes", declare the NodeShapes with their sh:targetClass and other constraints:
    NodeShapes tab of the SHACL Excel template

  • In tab "PropertyShapes", make one "section" (blue line) per node shape, and declare the property shapes attached to each node shape:
    PropertyShapes tab of the SHACL Excel template

    • The link to the node shape is made in column ^sh:property.
    • The predicate (or path) is in column sh:path. Property paths are supported, you can write them either the SHACL way Turtle, e.g. [sh:inversePath foaf:knows], or the SPARQL way, e.g. ^foaf:knows, which will be converted automagically in SHACL.
    • The URI of the property shape is computed automatically in column URI, based on the line number.
    • SHACL constraints are in the corresponding columns :
      • sh:minCount : minimum cardinality that the predicate/path must have;
      • sh:maxCount : maximum cardinality that the predicate/path must have;
      • sh:nodeKind : type of nodes that the values must have (usually sh:IRI or sh:Literal);
      • sh:datatype : for literal values, the expected datatype of the values, e.g. xsd:string, xsd:integer, etc. ;
      • sh:class : expected class that the values of the predicate/path must have, if only one. If more than one, use the sh:or column;
      • sh:node : if needed, expected shape that the values of the predicate/path must follow. This must be a reference to a URI of NodeShape from the first sheet;
      • etc.
    • You can add more columns as needed. See the detailled xls2rdf converter documentation for all possible features.

Convert the Excel using xls2rdf

Once you have filled in the Excel file, you can convert it to SHACL using the xsl2rdf converter. The converter is available in different packagings : online API, command-line app, Java lib, and also an online Excel conversion form which is the most practical solution to start with :

  1. Upload your Excel file
  2. Check the box at the bottom "Ignore SKOS post-processings"
  3. Click on "Convert" and download the resulting SHACL file.

Test in the documentation generator

Test how your SHACL looks like by uploading it in the documentation generator.

Navigate the graph

This kind of SHACL specification is also used to configure and fine-tune the Sparnatural query builder Sparnatural can use plain SHACL but it has its own custom SHACL Excel template with additionnal annotations.

For more information about how to configure Sparnatural in SHACL, see Sparnatural documentation website.