Rdf 使用两种不同的@type压缩JSON-LD属性?

Rdf 使用两种不同的@type压缩JSON-LD属性?,rdf,json-ld,Rdf,Json Ld,我试图压缩JSON-LD文档,见下文(我们使用URN,但URL也会出现同样的问题)。我希望在以下两种用法中,“org:example:property:schema;2”被压缩为schema,和架构属性的嵌套对象也被合理压缩。不幸的是,这似乎到目前为止是不可能的 [ { "@id": "org:example:ExampleThing", "org:example:property:contents;2": [

我试图压缩JSON-LD文档,见下文(我们使用URN,但URL也会出现同样的问题)。我希望在以下两种用法中,
“org:example:property:schema;2”
被压缩为
schema
架构属性的嵌套对象也被合理压缩。不幸的是,这似乎到目前为止是不可能的

[
  {
    "@id": "org:example:ExampleThing",
    "org:example:property:contents;2": [
          {
        "@type": "org:example:class:Property;2",
        "org:example:property:schema;2": {
          "@id": "org:example:instance:Schema:integer;2"
        }
      }
    ]
  },
  {
    "@id": "org:example:ExampleThing2",
    "org:example:property:contents;2": [
      {
        "@type": "org:example:class:Property;2",
        "org:example:property:schema;2": {
            "@type": "org:example:class:Enum;2",
            "org:example:property:valueSchema;2": {
                "@id": "org:example:instance:Schema:string;2"
            }
        }
      }
    ]
  }
]
我想说的是:

[
    {
      "@id": "org:example:ExampleThing",
      "contents": {
        "@type": "Property",
        "schema": {
          "@id": "integer"
        }
      }
    },
    {
      "@id": "org:example:ExampleThing2",
      "contents": {
        "@type": "Property",
        "schema": {
          "@type": "Enum",
          "valueSchema": "string"
        }
      }
    }
  ]
我得到的最接近的是以下上下文。然而,在它里面,
org:example:instance:Schema:integer;2
未按要求压实。将
“@type”:“@vocab”
添加到
schema
定义可以解决
ExampleThing
的问题,但是
schema
术语与
ExampleThing2
中属性的用法不匹配,因此它没有被压缩到那里

{
  "Property": { "@id": "org:example:class:Property;2" },
  "Enum": { "@id": "org:example:class:Enum;2" },
  "contents": { "@id": "org:example:property:contents;2" },
  "schema": { "@id": "org:example:property:schema;2" },
  "valueSchema": {
      "@id": "org:example:property:valueSchema;2",
      "@type": "@vocab"
  },
  "integer": { "@id": "org:example:instance:Schema:integer;2" },
  "string": { "@id": "org:example:instance:Schema:string;2" }
}

你所拥有的和你想要的非常接近。你可以在这里查一下

主要问题是,
“org:example:instance:Schema:integer;2”
值无法进一步压缩,因为
@id
的值被视为相对于文档位置或
@base
的虹膜。您可以在上下文中添加一个
@base
声明,这可以让您更接近上下文。您可以更好地使用作用域上下文,并在
属性
模式
下的上下文作用域中使用不同的
@base

如果不这样做,则压实结果如下所示:

{
  "@context": {
    "Property": {"@id": "org:example:class:Property;2"},
    "Enum": {"@id": "org:example:class:Enum;2"},
    "contents": {"@id": "org:example:property:contents;2"},
    "schema": {"@id": "org:example:property:schema;2"},
    "valueSchema": {
      "@id": "org:example:property:valueSchema;2",
      "@type": "@vocab"
    },
    "integer": {"@id": "org:example:instance:Schema:integer;2"},
    "string": {"@id": "org:example:instance:Schema:string;2"}
  },
  "@graph": [
    {
      "@id": "org:example:ExampleThing",
      "contents": {
        "@type": "Property",
        "schema": {
          "@id": "org:example:instance:Schema:integer;2"
        }
      }
    },
    {
      "@id": "org:example:ExampleThing2",
      "contents": {
        "@type": "Property",
        "schema": {
          "@type": "Enum",
          "valueSchema": "string"
        }
      }
    }
  ]
}

您可以在规范部分阅读更多内容。

谢谢!不幸的是,我不能在这里实现我想实现的目标,但我想我不得不将就一下。