Skip to content

Commit 2c6ea76

Browse files
committed
feat(ro-crate): ✨ refine constraint enforcing metadata descriptor existence
1 parent 1a91aa4 commit 2c6ea76

1 file changed

Lines changed: 26 additions & 16 deletions

File tree

rocrate_validator/profiles/ro-crate/must/1_file-descriptor_metadata.ttl

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,32 @@
2121
@prefix validator: <https://github.com/crs4/rocrate-validator/> .
2222

2323

24+
ro-crate:ROCrateMetadataFileDescriptorExistence
25+
a sh:NodeShape ;
26+
sh:targetNode sh:Graph ;
27+
sh:name "RO-Crate Metadata File Descriptor entity existence" ;
28+
sh:description "The RO-Crate JSON-LD MUST contain a Metadata File Descriptor entity named `ro-crate-metadata.json` and typed as `schema:CreativeWork`" ;
29+
30+
sh:sparql [
31+
a sh:SPARQLConstraint ;
32+
sh:name "RO-Crate Metadata File Descriptor entity existence" ;
33+
sh:description """Check if the RO-Crate Metadata File Descriptor entity exists,
34+
i.e., if there exists an entity with @id `ro-crate-metadata.json` and type `schema:CreativeWork`""" ;
35+
sh:message "The root of the document MUST have an entity with @id `ro-crate-metadata.json`" ;
36+
sh:prefixes ro-crate:sparqlPrefixes ;
37+
sh:select """
38+
SELECT $this
39+
WHERE {
40+
FILTER NOT EXISTS {
41+
?crate a schema:Dataset .
42+
?md schema:about ?crate .
43+
?md a schema:CreativeWork .
44+
FILTER( STRENDS(STR(?md), "ro-crate-metadata.json") )
45+
}
46+
}
47+
""" ;
48+
] .
49+
2450
ro-crate:FindROCrateMetadataFileDescriptorEntity a sh:NodeShape, validator:HiddenShape;
2551
sh:name "Identify the RO-Crate Metadata File Descriptor" ;
2652
sh:description """The RO-Crate Metadata File Descriptor entity describes the RO-Crate itself, and it is named as `ro-crate-metadata.json`.
@@ -47,22 +73,6 @@ ro-crate:FindROCrateMetadataFileDescriptorEntity a sh:NodeShape, validator:Hidde
4773
sh:object ro-crate:ROCrateMetadataFileDescriptor ;
4874
] .
4975

50-
ro-crate:ROCrateMetadataFileDescriptorExistence
51-
a sh:NodeShape ;
52-
sh:name "RO-Crate Metadata File Descriptor entity existence" ;
53-
sh:description "The RO-Crate JSON-LD MUST contain a Metadata File Descriptor entity named `ro-crate-metadata.json` and typed as `schema:CreativeWork`" ;
54-
sh:targetClass ro-crate:ROCrateMetadataFileDescriptor ;
55-
sh:property [
56-
a sh:PropertyShape ;
57-
sh:name "RO-Crate Metadata File Descriptor entity existence" ;
58-
sh:description """Check if the RO-Crate Metadata File Descriptor entity exists,
59-
i.e., if there exists an entity with @id `ro-crate-metadata.json` and type `schema:CreativeWork`""" ;
60-
sh:path rdf:type ;
61-
sh:hasValue ro-crate:ROCrateMetadataFileDescriptor ;
62-
sh:minCount 1 ;
63-
sh:message "The root of the document MUST have an entity with @id `ro-crate-metadata.json`" ;
64-
] .
65-
6676
ro-crate:ROCrateMetadataFileDescriptorRecommendedProperties a sh:NodeShape ;
6777
sh:name "RO-Crate Metadata File Descriptor REQUIRED properties" ;
6878
sh:description """RO-Crate Metadata Descriptor MUST be defined

0 commit comments

Comments
 (0)