如何使用SHACL验证json-ld 1.1数据图?

问题描述 投票:0回答:1

数据图:(json-ld)

{
    "@context": {
       "@version": 1.1,
        "pav": "http://purl.org/pav/",
        "xsd": "http://www.w3.org/2001/XMLSchema#",
        "skos": "http://www.w3.org/2004/02/skos/core#",
        "reproterms": "https://raw.githubusercontent.com/ReproNim/schema-standardization/master/terms/",
        "reproschema": "https://raw.githubusercontent.com/ReproNim/schema-standardization/master/schemas/",
        "schema": "http://schema.org/",
        "@language": "en",
        "prefLabel": {
            "@id": "skos:prefLabel",
            "@container": "@language"
        }
    },
    "@type": "reproschema:Activity",
    "@id": "phq9_data",
    "prefLabel": "PHQ-9 Assessment"
}

。ttl格式的数据图:

@prefix activity: <https://raw.githubusercontent.com/ReproNim/schema-standardization/master/activities/> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix schema: <http://schema.org/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
@prefix reproterms: <https://raw.githubusercontent.com/ReproNim/schema-standardization/master/terms/> .
@prefix activity: <https://raw.githubusercontent.com/ReproNim/schema-standardization/master/activities/> .
@prefix reproschema: <https://raw.githubusercontent.com/ReproNim/schema-standardization/master/schemas/> .

activity:PHQ-9/phq9_schema
    a reproschema:Activity ;
    skos:prefLabel "PHQ-9 Assessment" .

形状图:

@prefix dash: <http://datashapes.org/dash#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix schema: <http://schema.org/> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix reproterms: <https://raw.githubusercontent.com/ReproNim/schema-standardization/master/terms/> .
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
@prefix reproschema: <https://raw.githubusercontent.com/ReproNim/schema-standardization/master/schemas/> .

reproschema:ActivityShape
    a sh:NodeShape ;
    sh:targetClass reproschema:Activity;

    sh:property [
        sh:path skos:prefLabel ;
        sh:datatype rdf:langString ;
        sh:minCount 1 ;
        sh:maxCount 1 ;
    ] .

如果上下文包含@version:1.1,它似乎不起作用;给出一个错误。如何使验证对以JSON-LD 1.1表示的图起作用?我也以乌龟格式添加了数据图。

rdf json-ld shacl
1个回答
0
投票

约束sh:datatype rdf:langString要求属性的所有值都具有语言标记。因此,例如,skos:prefLabel“ PHQ-9评估” @en可以工作。或将约束更改为sh:datatype xsd:string。

© www.soinside.com 2019 - 2024. All rights reserved.