diff --git a/README.md b/README.md index 39641fa..3ca8140 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,8 @@ At least with [Apache Jena SHACL](https://jena.apache.org/documentation/shacl/in If you take our [template repo](https://github.com/skohub-io/vocab-template) as a starting point the validation against this shape is already built in. +Run `scripts/messages.sh` to get a list of shape messages to summarize the constraints checked by shapes. + ## Check with Apache Jena SHACL To use this shape with [Apache Jena](https://jena.apache.org/download/index.cgi) SHACL validate your file with `shacl validate --shapes skos.shacl.ttl --data YOUR-DATA.ttl` diff --git a/scripts/messages.rq b/scripts/messages.rq new file mode 100644 index 0000000..6ef9ac4 --- /dev/null +++ b/scripts/messages.rq @@ -0,0 +1,11 @@ +prefix sh: + +SELECT DISTINCT ?type ?msg { + ?shape sh:message ?msg . + #FILTER (lang(?msg) = 'en') + + OPTIONAL { ?shape sh:severity ?severity } + BIND(STRAFTER(STR(COALESCE(?severity,sh:Violation)),'#') as ?type) + + #filter(regex(?msg,"S[0-9]+")) +} ORDER BY ?type diff --git a/scripts/messages.sh b/scripts/messages.sh new file mode 100755 index 0000000..581981c --- /dev/null +++ b/scripts/messages.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +sparql() { + data=$1 + query=$2 + docker run --rm -v $query:/rdf/query.rq --mount type=bind,source=$data,target=/rdf/data.ttl skohub/jena:4.6.1 arq --data /rdf/data.ttl --query /rdf/query.rq --results=TSV +} + +sparql $(pwd)/skos.shacl.ttl $(pwd)/scripts/messages.rq diff --git a/skos.shacl.ttl b/skos.shacl.ttl index 65f0afa..a62f106 100644 --- a/skos.shacl.ttl +++ b/skos.shacl.ttl @@ -43,14 +43,14 @@ skos: sh:minCount 1; sh:severity sh:Warning ; sh:datatype rdf:langString ; - sh:message "Each skos:Concept has to provide a skos:prefLabel" + sh:message "Each skos:Concept should provide a skos:prefLabel" ] ; sh:property [ sh:description "S14 A resource has no more than one value of skos:prefLabel per language tag." ; sh:path skos:prefLabel ; sh:datatype rdf:langString ; sh:uniqueLang true ; - sh:message "Each skos:Concept has to provide a unique language for skos:prefLabel" ; + sh:message "S14: Each skos:Concept has to provide a unique language for skos:prefLabel" ; ] ; sh:property [ sh:path skos:altLabel ; @@ -62,7 +62,7 @@ skos: # min count is checked above sh:property [ sh:path skos:prefLabel ; - sh:description "\"Constraint S13: skos:prefLabel, skos:altLabel and skos:hiddenLabel must be disjoint\"" ; + sh:message "S13: skos:prefLabel, skos:altLabel and skos:hiddenLabel must be disjoint" ; sh:disjoint skos:altLabel ; sh:disjoint skos:hiddenLabel ; # sh:minCount 1 ; @@ -70,7 +70,7 @@ skos: ] ; sh:property [ sh:path skos:altLabel ; - sh:description "\"Constraint S13: skos:prefLabel, skos:altLabel and skos:hiddenLabel must be disjoint\"" ; + sh:message "S13: skos:prefLabel, skos:altLabel and skos:hiddenLabel must be disjoint" ; sh:disjoint skos:hiddenLabel ; sh:disjoint skos:prefLabel ; sh:name "alt label" ; @@ -125,7 +125,7 @@ skos: # ] ; sh:property [ sh:path skos:related ; - sh:description "S27 skos:related is disjoint with the property skos:broaderTransitive." ; + sh:message "S27: skos:related is disjoint with the property skos:broaderTransitive" ; sh:disjoint skos:broader ; sh:disjoint skos:broaderTransitive ; sh:disjoint skos:narrower ; @@ -198,7 +198,7 @@ skos: a sh:SPARQLConstraint ; sh:prefixes skos: ; rdfs:comment "Ambiguous Notation References" ; - sh:description "Concepts should not have identlical skos:notation literals." ; + sh:description "Concepts should not have identical skos:notation literals." ; sh:message "the concept has the same notation {$value} as {$path}" ; sh:select """ SELECT $this (?other as ?path) ?value