JSON-LD框架不嵌入子元素

JSON-LD framing does not embed child elements

我正在尝试构建一个 json-ld 对象(这里是 solid-terms ontology) from a previously flattened json-ld object. I tried to reproduce the example given in the W3C editors draft.

使用这个框架:

{
  "@type": "http://www.w3.org/2002/07/owl#Ontology",
  "contains": {
    "@type": "http://www.w3.org/2000/01/rdf-schema#Class"
  }
}

它只是导致 ontology 本身位于顶层,没有嵌套的 Class 条目。

{
  "@graph": [
    {
      "@id": "http://www.w3.org/ns/solid/terms",
      "@type": "http://www.w3.org/2002/07/owl#Ontology",
      "http://purl.org/dc/terms/issued": {
        "@type": "http://www.w3.org/2001/XMLSchema#date",
        "@value": "2015-11-16"
      },
      "http://purl.org/dc/terms/modified": {
        "@type": "http://www.w3.org/2001/XMLSchema#date",
        "@value": "2018-01-24"
      },
      "http://www.w3.org/2000/01/rdf-schema#label": {
        "@language": "en",
        "@value": "Solid terms"
      },
      "https://creativecommons.org/ns#attributionURL": {
        "@id": "http://www.w3.org/ns/solid/terms"
      },
      "https://creativecommons.org/ns#license": {
        "@id": "https://creativecommons.org/publicdomain/zero/1.0/"
      }
    }
  ]
}

我的框架有什么问题?请参阅游乐场示例:JSON-LD Playground

您的框架没有指定@context,因此contains没有任何语义。

A class 通过 http://www.w3.org/2000/01/rdf-schema#isDefinedBy 与 ontology 相关。所以如果你想在顶层有一个带有 Ontology 的文档,并且它定义的所有 classes 通过 "contains" 关键字嵌套,你必须使用这个框架:

{
  "@context": {
    "@vocab": "http://www.w3.org/2002/07/owl#",
    "rdfs": "http://www.w3.org/2000/01/rdf-schema#",
    "contains": {
      "@reverse": "rdfs:isDefinedBy"
    }
  },
  "@type": "Ontology",
  "contains": {}
}

Permalink to the playground showing this in action.