Schema.org JSON-LD 参考 [英] Schema.org JSON-LD reference

查看:49
本文介绍了Schema.org JSON-LD 参考的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个关于在另一个 JSON-LD schema.org 标记中引用 JSON-LD schema.org 标记的问题.我有一个包含主要事件的页面,位于 http://event.com/,这是它的 JSON-LD 标记.

I have a question about referencing a JSON-LD schema.org markup in another JSON-LD schema.org markup. I have a page with a main event which is located at http://event.com/ and here's the JSON-LD markup for it.

<script type="application/ld+json">
{
  "@context": "http://schema.org",
  "@type": "Event",
  "name": "MainEvent",
  "startDate": "2016-04-21T12:00",
  "location": {
    ...
  }
}
</script>

主事件有多个子事件位于例如 http://event.com/sub-event-1/ 和这里的 JSON-LD 标记:

Main event has multiple sub events located at for example http://event.com/sub-event-1/ and here's the JSON-LD markup for that:

<script type="application/ld+json">
{
  "@context": "http://schema.org",
  "@type": "Event",
  "name": "SubEvent",
  "startDate": "2016-04-21T12:00",
  "location": {
    ...
  }
}
</script>

我要做的是将子事件标记为主要事件的一部分.是否可以创建从主事件到子事件的引用?像这样:

What I'm trying to do is mark up the subevent as part of the main event. Is it possible to create a reference from the main event to sub event? Something like this:

<script type="application/ld+json">
{
  "@context": "http://schema.org",
  "@type": "Event",
  "name": "SubEvent",
  "startDate": "2016-04-21T12:00",
  "location": {
    ...
  }
  superEvent {
    "url": "http://event.com/"
  }
}
</script>

如果可能,参考的正确标记是什么.我找不到有关它的任何信息.

If it's possible, what's the correct markup for reference. I can't find any information about it.

或者是否需要像这样将 MainEvent 嵌入到每个子事件中:

Or is it required to embed the MainEvent in every single SubEvent like this:

<script type="application/ld+json">
{
  "@context": "http://schema.org",
  "@type": "Event",
  "name": "SubEvent",
  "startDate": "2016-04-21T12:00",
  "location": {
    ...
  },
  "superEvent": {
    "@type": "Event",
    "name": "MainEvent",
    "startDate": "2016-04-21T12:00",
    "location": {
    ...
    }
  }
}
</script>

推荐答案

您可以通过给节点一个 URI 来标识它,该 URI 在 @id 关键字中指定.此 URI 可用于引用该节点.

You can identify a node by giving it a URI, specified in the @id keyword. This URI can be used to reference that node.

请参阅 JSON 中的节点标识符"部分-LD规格

See the section "Node Identifiers" in the JSON-LD spec.

因此您的主要事件可以获得 URI http://example.com/2016-04-21#main-event:

So your main event could get the URI http://example.com/2016-04-21#main-event:

<script type="application/ld+json">
{
  "@id": "http://example.com/2016-04-21#main-event",
  "@context": "http://schema.org",
  "@type": "Event",
  "name": "MainEvent",
  "startDate": "2016-04-21T12:00"
}
</script>

并且您可以将此 URI 作为子事件的 superEvent 属性的值:

and you could give this URI as the value for the sub event’s superEvent property:

<script type="application/ld+json">
{
  "@context": "http://schema.org",
  "@type": "Event",
  "name": "SubEvent",
  "startDate": "2016-04-21T12:00",
  "superEvent": { "@id": "http://example.com/2016-04-21#main-event" }
}
</script>

(当然,您也可以为您的子事件指定一个 @id.这将允许您和其他人识别/引用此子事件.)

(You could of course give your sub event an @id, too. This would allow you and others to identify/reference this sub event.)

这篇关于Schema.org JSON-LD 参考的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆