Skip to content

Commit 39bd761

Browse files
committed
fix(ro-crate): 🐛 use SPARQL target to select the candidate RO-Crate metadata descriptor
1 parent 2abb275 commit 39bd761

1 file changed

Lines changed: 21 additions & 16 deletions

File tree

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

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
1514
@prefix ro: <./> .
1615
@prefix ro-crate: <https://github.com/crs4/rocrate-validator/profiles/ro-crate/> .
1716
@prefix dct: <http://purl.org/dc/terms/> .
@@ -20,22 +19,19 @@
2019
@prefix sh: <http://www.w3.org/ns/shacl#> .
2120
@prefix validator: <https://github.com/crs4/rocrate-validator/> .
2221

23-
24-
ro-crate:ROCrateMetadataFileDescriptorExistence
25-
a sh:NodeShape ;
22+
ro-crate:ROCrateMetadataFileDescriptorExistence a sh:NodeShape ;
2623
sh:targetNode sh:Graph ;
2724
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-
25+
sh:description """The RO-Crate JSON-LD MUST contain a Metadata File Descriptor entity named `ro-crate-metadata.json` and typed as `schema:CreativeWork`""" ;
3026
sh:sparql [
3127
a sh:SPARQLConstraint ;
3228
sh:name "RO-Crate Metadata File Descriptor entity existence" ;
3329
sh:description """Check if the RO-Crate Metadata File Descriptor entity exists,
3430
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`" ;
31+
sh:message """The root of the document MUST have an entity with @id `ro-crate-metadata.json`, typed as `schema:CreativeWork` and with an `about` property referencing the Root Data Entity""" ;
3632
sh:prefixes ro-crate:sparqlPrefixes ;
3733
sh:select """
38-
SELECT $this
34+
SELECT ?this
3935
WHERE {
4036
FILTER NOT EXISTS {
4137
?crate a schema:Dataset .
@@ -45,9 +41,9 @@ ro-crate:ROCrateMetadataFileDescriptorExistence
4541
}
4642
}
4743
""" ;
48-
] .
44+
] .
4945

50-
ro-crate:FindROCrateMetadataFileDescriptorEntity a sh:NodeShape, validator:HiddenShape;
46+
ro-crate:FindROCrateMetadataFileDescriptorEntity a sh:NodeShape, validator:HiddenShape ;
5147
sh:name "Identify the RO-Crate Metadata File Descriptor" ;
5248
sh:description """The RO-Crate Metadata File Descriptor entity describes the RO-Crate itself, and it is named as `ro-crate-metadata.json`.
5349
It can be identified by name according to the RO-Crate specification
@@ -76,10 +72,19 @@ ro-crate:FindROCrateMetadataFileDescriptorEntity a sh:NodeShape, validator:Hidde
7672
ro-crate:ROCrateMetadataFileDescriptorRecommendedProperties a sh:NodeShape ;
7773
sh:name "RO-Crate Metadata File Descriptor REQUIRED properties" ;
7874
sh:description """RO-Crate Metadata Descriptor MUST be defined
79-
according with the requirements details defined in
80-
[RO-Crate Metadata File Descriptor](https://www.researchobject.org/ro-crate/1.1/root-data-entity.html#ro-crate-metadata-file-descriptor)""";
81-
sh:targetClass ro-crate:ROCrateMetadataFileDescriptor ;
82-
sh:property [
75+
according with the requirements details defined in [RO-Crate Metadata File Descriptor](https://www.researchobject.org/ro-crate/1.1/root-data-entity.html#ro-crate-metadata-file-descriptor)""" ;
76+
sh:target [
77+
a sh:SPARQLTarget ;
78+
sh:prefixes ro-crate:sparqlPrefixes ;
79+
sh:select """
80+
SELECT ?this
81+
WHERE {
82+
?this ?p ?o .
83+
FILTER( STRENDS(STR(?this), "ro-crate-metadata.json") )
84+
}
85+
""" ;
86+
] ;
87+
sh:property [
8388
a sh:PropertyShape ;
8489
sh:name "Metadata File Descriptor entity type" ;
8590
sh:description "Check if the RO-Crate Metadata File Descriptor has `@type` CreativeWork, as per schema.org" ;
@@ -89,11 +94,11 @@ ro-crate:ROCrateMetadataFileDescriptorRecommendedProperties a sh:NodeShape ;
8994
sh:hasValue schema_org:CreativeWork ;
9095
sh:message "The RO-Crate metadata file MUST be a CreativeWork, as per schema.org" ;
9196
] ;
92-
sh:property [
97+
sh:property [
9398
a sh:PropertyShape ;
9499
sh:name "Metadata File Descriptor entity: `about` property" ;
95100
sh:description """Check if the RO-Crate Metadata File Descriptor has an `about` property referencing the Root Data Entity""" ;
96-
sh:maxCount 1;
101+
sh:maxCount 1 ;
97102
sh:minCount 1 ;
98103
sh:nodeKind sh:IRI ;
99104
sh:path schema_org:about ;

0 commit comments

Comments
 (0)