por*_*low 8 schema.org json-ld
我有一个关于在另一个JSON-LD schema.org标记中引用JSON-LD schema.org标记的问题.我有一个主要事件的页面位于,http://event.com/这里是JSON-LD标记.
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "Event",
"name": "MainEvent",
"startDate": "2016-04-21T12:00",
"location": {
...
}
}
</script>
Run Code Online (Sandbox Code Playgroud)
主事件有多个子事件,例如http://event.com/sub-event-1/,这里是JSON-LD标记:
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "Event",
"name": "SubEvent",
"startDate": "2016-04-21T12:00",
"location": {
...
}
}
</script>
Run Code Online (Sandbox Code Playgroud)
我要做的是将子事件标记为主事件的一部分.是否可以创建从主事件到子事件的引用?像这样的东西:
<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>
Run Code Online (Sandbox Code Playgroud)
如果可能,什么是正确的标记供参考.我找不到任何有关它的信息.
或者是否需要在每个SubEvent中嵌入MainEvent,如下所示:
<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>
Run Code Online (Sandbox Code Playgroud)
uno*_*nor 18
您可以通过为节点指定@id关键字中指定的URI来标识节点.此URI可用于引用该节点.
请参阅JSON-LD规范中的" 节点标识符 " 部分.
所以你的主要事件可以得到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>
Run Code Online (Sandbox Code Playgroud)
并且您可以将此URI作为子事件superEvent属性的值:
<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>
Run Code Online (Sandbox Code Playgroud)
(你当然也可以给你的子事件@id.这将允许你和其他人识别/引用这个子事件.)
您正在寻找什么节点标识符(请参阅http://www.w3.org/TR/json-ld/#node-identifiers)。您以 URL 的形式为每个实体分配一个唯一标识符,并在引用中使用它:
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@id": "http://event.com/#mainEvent",
"@type": "Event",
"name": "MainEvent",
"startDate": "2016-04-21T12:00",
"location": {
...
}
}
</script>
Run Code Online (Sandbox Code Playgroud)
在上面你看到我给这个事件一个@id. 我附加了一个片段 ( #mainEvent) 因为http://event.com/通常会标识页面本身。然后,您可以按如下方式引用该事件:
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "Event",
"name": "SubEvent",
"startDate": "2016-04-21T12:00",
"location": {
...
}
superEvent {
"@id": "http://event.com/#mainEvent"
}
}
</script>
Run Code Online (Sandbox Code Playgroud)
嵌入如您的示例所示也有效。在这种情况下,您将不需要标识符,因为很清楚什么引用了什么。