Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cognizone/semanticz-shaclviz
A tool to create flexible SHACL diagrams in PlantUML or yEd
https://github.com/cognizone/semanticz-shaclviz
diagrams plantuml rdf shacl yed
Last synced: about 12 hours ago
JSON representation
A tool to create flexible SHACL diagrams in PlantUML or yEd
- Host: GitHub
- URL: https://github.com/cognizone/semanticz-shaclviz
- Owner: cognizone
- License: apache-2.0
- Created: 2024-10-31T07:40:36.000Z (4 months ago)
- Default Branch: develop
- Last Pushed: 2025-01-07T12:05:58.000Z (about 1 month ago)
- Last Synced: 2025-01-07T13:19:18.994Z (about 1 month ago)
- Topics: diagrams, plantuml, rdf, shacl, yed
- Language: Kotlin
- Homepage:
- Size: 155 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# SHACL Viz
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:targetClass` of `sh:NodeShape`, not the `sh:NodeShape` themselves.
- class labels are taken from `dc:title` of the node shapes (falling back to `rdfs:label` of the `sh:targetClass`)
- diagram edges correspond to `sh:PropertyShape`s
- their labels are taken from `sh:name` (falling back to `sh: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)## Diagram Generation
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:targetClass` pointing to an IRI of a class
- each property shape
- must have an `sh:path` pointing to an IRI of a property.
- can have optionally these properties
- `sh:datatype`
- `sh:maxCount`
- `sh:minCount`
- labels are taken from `rdfs:label` of the target ontology class/ontology property in the path. In case there is a `dc:title` of the given class shape (resp. `sh:name` of the given property shape), it overrides the label of the ontology entity. If neither label is present, it is extracted from the IRI.## Minimal Example
```bash
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.## Make a class visualized as a field
```bash
echo "SELECT ?field {} VALUES ?field { }" > 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.## Only visualize required edges/fields
```bash
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`.## Generate TGF for advanced layout
```bash
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.
1. Open the TGF file in yEd editor.
2. Execute "Fit Node to Size" and "Hierarchical Layout" (or choose another layout)
3. Perform any manual editing/layout
4. Save the diagram as GraphML/Export it to the desired format (e.g. svg/png)