JSON-LD框架未嵌入子元素

时间:2019-02-25 06:27:00

标签: json-ld

我正在尝试从先前扁平化的json-ld对象构造一个json-ld对象(此处为solid-terms本体)。我试图重现W3C editors draft中给出的示例。

使用此框架:

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

这只会导致顶级本体本身,而不会嵌套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

1 个答案:

答案 0 :(得分:2)

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

一个类与http://www.w3.org/2000/01/rdf-schema#isDefinedBy的本体有关。因此,如果您想在顶层使用本体论编写文档,并且该文档定义的所有类都通过“ 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