Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Copyright (c) 2025 eScience Lab, The University of Manchester
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

@prefix ro: <./> .
@prefix ro-crate: <https://github.com/crs4/rocrate-validator/profiles/ro-crate/> .
@prefix five-safes-crate: <https://github.com/eScienceLab/rocrate-validator/profiles/five-safes-crate/> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix schema: <http://schema.org/> .
@prefix purl: <http://purl.org/dc/terms/> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix validator: <https://github.com/crs4/rocrate-validator/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .



five-safes-crate:ReferenceToWorkflowCrate
a sh:NodeShape ;
sh:name "RootDataEntity" ;
sh:targetClass ro-crate:RootDataEntity ;

# RootDataEntity MUST have an mainEntity property
sh:property [
a sh:PropertyShape ;
sh:name "mainEntity" ;
sh:path schema:mainEntity ;
sh:minCount 1 ;
sh:maxCount 1 ;
sh:nodeKind sh:IRI ;
sh:severity sh:Violation ;
sh:message "The RootDataEntity MUST have exactly one schema:mainEntity property that is an IRI." ;
] ;

# The mainEntity of a RootDataEntity MUST be a Dataset
sh:property [
a sh:PropertyShape ;
sh:name "mainEntity" ;
sh:path schema:mainEntity ;
sh:class schema:Dataset ;
sh:severity sh:Violation ;
sh:message "The mainEntity pointed to by the RootDataEntity MUST be of type schema:Dataset" ;
] .

five-safes-crate:mainEntityHasProperConformsTo
Copy link

@alexhambley alexhambley Oct 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not 100% sure, but I think this may only validate the prefix when conformsTo exists. In other words if conformsTo is missing, the violation might not report (?)
sh:minCount 1 ; might be required. Worth a test to see.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right. Added a constraint for that and a corresponding test.

a sh:NodeShape ;
sh:name "mainEntity" ;
sh:description "The mainEntity of the RootDataEntity MUST have a conformsTo property with an IRI starting with https://w3id.org/workflowhub/workflow-ro-crate" ;
sh:targetObjectsOf schema:mainEntity ;
sh:sparql [
a sh:SPARQLConstraint ;
sh:name "conformsTo" ;
sh:message "conformsTo IRI must start with https://w3id.org/workflowhub/workflow-ro-crate" ;
sh:select """
PREFIX schema: <http://schema.org/>
PREFIX purl: <http://purl.org/dc/terms/>
SELECT $this WHERE {
$this purl:conformsTo ?iri .
FILTER(!STRSTARTS(STR(?iri), "https://w3id.org/workflowhub/workflow-ro-crate"))
}
""" ;
] .
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Copyright (c) 2025 eScience Lab, The University of Manchester
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

@prefix ro: <./> .
@prefix ro-crate: <https://github.com/crs4/rocrate-validator/profiles/ro-crate/> .
@prefix five-safes-crate: <https://github.com/eScienceLab/rocrate-validator/profiles/five-safes-crate/> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix schema: <http://schema.org/> .
@prefix purl: <http://purl.org/dc/terms/> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix validator: <https://github.com/crs4/rocrate-validator/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .


five-safes-crate::DatasetMustHaveDistributionIfURI
a sh:NodeShape ;
sh:name "mainEntity" ;
sh:targetObjectsOf schema:mainEntity ;
sh:description "If mainEntity has an HTTP(S) @id, it SHOULD have a distribution that is an HTTP(S) URL." ;

sh:sparql [
a sh:SPARQLConstraint ;
sh:name "distribution" ;
sh:description "If mainEntity has an HTTP(S) @id, it SHOULD have a distribution that is an HTTP(S) URL." ;
sh:prefixes ro-crate:sparqlPrefixes ;
sh:select """
SELECT $this
WHERE {
FILTER (STRSTARTS(STR($this), "http://") || STRSTARTS(STR($this), "https://")) .
FILTER NOT EXISTS {
$this schema:distribution ?dist .
FILTER (STRSTARTS(STR(?dist), "http://") || STRSTARTS(STR(?dist), "https://")) .
}
}
""" ;
sh:severity sh:Warning ;
sh:message "If mainEntity has an HTTP(S) @id SHOULD have at least one distribution with an HTTP(S) URL." ;
] .
Loading