互连“组织”和“workFor”微数据?

时间:2016-01-25 11:32:40

标签: schema.org microdata

我们有一个网站,其中联系页面由两部分组成:第一部分有关组织的信息(姓名,电话,电子邮件,注册码),第二部分是所有工作人员的联系人列表(姓名,职位,电子邮件和电话号码。)

我可以毫无问题地将微数据添加到各个字段。但我还希望将组织和人员微观数据相互链接。因此,对于Persons,“worksFor”itemprop信息直接来自组织itemprop =“name”,稍后,在组织下,工作者列出了“employees”或“worker”itemprop。

<div itemscope itemtype="http://schema.org/Organization">
    <span itemprop="name">Organization XXX</span>
    <span itemprop="telephone">1234567</span>
    <span itemprop="email">orgemail@org.org</span>
    <span id="worklink" itemprop="worksfor">Organization YYY</span>
</div>
    <table>
        <tr itemscope itemtype="http://schema.org/Person" itemref="worklink">
            <td itemprop="name">Helmut York</td>
            <td itemprop="jobTitle">Analyst</td>
            <td itemprop="email">helmut@org.org</td>
        </tr>

        <tr itemscope itemtype="http://schema.org/Person" itemref="worklink">
            <td itemprop="name">Julius Xing</td>
            <td itemprop="name">Analyst</td>
            <td itemprop="email">julius@org.org</td>
        </tr>
    </table>

然而,问题在于,使用此代码,组织也会获得“worksFor”itemprop,当然,这会在Google结构化数据测试工具中出错。任何想法如何解决这个问题? schema.org中的itemref属性记录很少。

1 个答案:

答案 0 :(得分:0)

您可以使用 itemref属性执行此操作,但必须将id="worklink"itemprop="worksFor"¹移动到应添加为属性值的元素

所以看起来像这样:

<div itemprop="worksFor" itemscope itemtype="http://schema.org/Organization" id="worklink">
</div>

<table>
  <tr itemscope itemtype="http://schema.org/Person" itemref="worklink"></tr>
  <tr itemscope itemtype="http://schema.org/Person" itemref="worklink"></tr>
</table>

但是现在您必须确保Organization项目没有其他Microdata项目作为父项,否则它也会通过worksFor属性添加到此项目中。

itemref的替代方法是使用itemid属性并将组织URI作为值引用,但每个消费者可能都不支持。

¹请注意,URI区分大小写。该属性为ẁorksFor,而非worksfor