如何从多个其他项目中引用另一个项目声明,以满足schema.org的要求?

问题描述 投票:0回答:1

在搜索了很多关于如何正确地从一个项目引用到另一个项目的信息后,我找到了以下方法 这个最小的例子 展示了如何引用一个 Organization 项目 branchOfHotel 项目。它定义了属性 itemprop="branchOf" 在...上 Organization的属性。Hotel 项后,它引用它。

<div itemprop="branchOf" itemscope itemtype="http://schema.org/Organization" id="schema-organization">
 <h1 itemprop="name">The Hotel Chain</h1>
</div>

<div itemscope itemtype="http://schema.org/Hotel" itemref="schema-organization">
 <h2 itemprop="name">Hotel Location 1</h2>
</div>

这个例子是有效的。

但现在我需要添加一个 Person 那是 Organization. 我可以用同样的概念来定义 itemprop="worksFor" 在...上 Organization然后参考我的 Person,像这样。

<div itemprop="worksFor" itemscope itemtype="http://schema.org/Organization" id="schema-organization">
 <h1 itemprop="name">The Hotel Chain</h1>
</div>
<div itemscope itemtype="http://schema.org/Hotel" itemref="schema-organization">
 <h2 itemprop="name">Hotel Location 1</h2>
</div>
<div itemscope itemtype="http://schema.org/Person" itemref="schema-organization">
    <div itemprop="name">John Doe</div>
</div>

还有... Person 正确地获得其 worksFor 属性来显示 Organization 这里。

但现在我必须要删除 itemref 来自 Hotel,否则它就会抱怨说它不认识某个 worksFor 属性。如果我这样做,那么 Hotel 不再引用 Organization 以任何方式,因此它不是它的一个分支。

如此看来,这是一个非此即彼的局面。

我怎样才能同时声明这两种情况呢?该 Person 需要工作 OrganizationHotel 需要成为一个分支。Organization.

schema schema.org semantic-markup
1个回答
1
投票

你可以使用 itemid 并从每个实体中引用相同的 itemid,例如

<div itemscope itemtype="http://schema.org/Organization" itemid="#organization">
 <h1 itemprop="name">The Hotel Chain</h1>
</div>
<div itemscope itemtype="http://schema.org/Hotel" >
 <h2 itemprop="name">Hotel Location 1</h2>
 <meta itemprop="branchOf" itemscope itemid="#organization"/>
</div>
<div itemscope itemtype="http://schema.org/Person">
    <div itemprop="name">John Doe</div>
    <meta itemprop="worksFor" itemscope itemid="#organization"/>
</div>
© www.soinside.com 2019 - 2024. All rights reserved.