簡體   English   中英

如何使用 SHACL 驗證 json-ld 1.1 數據圖?

[英]How to validate json-ld 1.1 data graphs with SHACL?

數據圖:(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 中表示的圖形進行驗證? 我也添加了海龜格式的數據圖。

約束 sh:datatype rdf:langString 要求屬性的所有值都具有語言標記。 因此,例如, skos:prefLabel "PHQ-9 Assessment"@en 會起作用。 或者將約束更改為 sh:datatype xsd:string。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM