This tool allows you to visualize SHACL data model files as a UML-like class diagram with the following features:
- diagram nodes correspond to the target classes of
sh:targetClassofsh:NodeShape, not thesh:NodeShapethemselves. - class labels are taken from
dc:titleof the node shapes (falling back tordfs:labelof thesh:targetClass) - diagram edges correspond to
sh:PropertyShapes - their labels are taken from
sh:name(falling back tosh:description) - configurable RDFS classes/datatypes that will be visualized as fields (not edges) in the diagram.
- configurable filter to ignore certain domainClass-property-rangeClass combinations (e.g. to select only required elements for the diagram)
- export formats - PlantUML (auto-layout), TGF graph importable by yEd (for advanced layouts and manual editing)
The diagram generation works specific form of a SHACL file representing a data model with the following constraints:
- a node shape to be visualized must have
sh:targetClasspointing to an IRI of a class
- each property shape
- must have an
sh:pathpointing to an IRI of a property. - can have optionally these properties
sh:datatypesh:maxCountsh:minCount
- must have an
- labels are taken from
rdfs:labelof the target ontology class/ontology property in the path. In case there is adc:titleof the given class shape (resp.sh:nameof the given property shape), it overrides the label of the ontology entity. If neither label is present, it is extracted from the IRI.
export SHACL_FILE=src/test/resources/example.ttl
export OUTPUT_FILE=src/test/resources/example.puml
./gradlew run --args="$SHACL_FILE $OUTPUT_FILE"This generates a PlantUML file taking into account all property shapes, and considering only data types as fields.
echo "SELECT ?field {} VALUES ?field { <http://www.w3.org/2001/XMLSchema#string> <http://www.w3.org/2004/02/skos/core#Concept> }" > fieldQuery.rq
export SHACL_FILE=src/test/resources/example.ttl
export OUTPUT_FILE=src/test/resources/example.puml
./gradlew run --args="$SHACL_FILE $OUTPUT_FILE --fieldQuery=fieldQuery.rq --hideOrphanNodes=false"Generates the same diagram, but showing skos:Concept as fields instead of nodes. The --hideOrphanNodes=false flag ensures that the also nodes (here 'string') without any in/out links and fields are shown in the diagram.
export SHACL_FILE=src/test/resources/example.ttl
export OUTPUT_FILE=src/test/resources/example.puml
./gradlew run --args="$SHACL_FILE $OUTPUT_FILE --filterQuery=classpath:/edges-required-only.rq"Filters out all constraints (edges/fields) that have minCount < 1.
export SHACL_FILE=src/test/resources/example.ttl
export OUTPUT_FILE=src/test/resources/example.tgf
./gradlew run --args="$SHACL_FILE --outputFormat tgf $OUTPUT_FILE"Generates a TGF graph.
- Open the TGF file in yEd editor.
- Execute "Fit Node to Size" and "Hierarchical Layout" (or choose another layout)
- Perform any manual editing/layout
- Save the diagram as GraphML/Export it to the desired format (e.g. svg/png)