HTML5 微数据 - itemref 到另一个 itemscope(人为组织工作) [英] HTML5 Microdata - itemref to another itemscope (Person works for Organization)

查看:13
本文介绍了HTML5 微数据 - itemref 到另一个 itemscope(人为组织工作)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

某个组织的网站,例如Sun Industries",想要添加员工列表.该组织的地址和联系信息已经出现在网页上,但员工名单将在其他地方.

所以我们有

<span itemprop="name">Sun Industries</span>,<span itemprop="location" itemscope itemtype="http://schema.org/Place"><span itemprop="address" itemscope itemtype="http://schema.org/PostalAddress"><span itemprop="streetAddress">Technologies Street 42</span>,<span itemprop="addressLocality">Venustown</span><span itemprop="postalCode">98765</span></span></span>

然后在我们将拥有的 HTML5 代码中

<span itemprop="name">John Doe</span>,<span itemprop="jobTitle">销售经理</span>

我们如何将organization"和employee-1"这两个对象联系在一起?

我尝试将以下孩子添加到employee-1"对象

但这不起作用(至少在 Google 的结构化数据测试工具中不起作用).

在这种情况下如何正确使用微数据属性 itemref?

为了清楚起见,我还尝试了以下操作:

  • itemprop="worksFor" 添加到组织"对象.
  • itemref="organization" 添加到员工"对象.

所以

<span itemprop="name">Sun Industries</span>,...

...<div id="employee-1" itemscope itemtype="http://schema.org/Person" itemref="organization"><span itemprop="name">John Doe</span>,<span itemprop="jobTitle">销售经理</span>

但这给了我一个警告:页面包含属性worksfor",它不是架构的一部分.用于组织"对象.

解决方案

好吧,实际上您的最后一个代码片段看起来不错.也许使用 Yandex Validator 输出会更清晰

人itemType = http://schema.org/Person效劳于组织itemType = http://schema.org/Organization名称 = 太阳工业姓名 = 约翰·多伊职位名称 = 销售经理

几个其他工作示例.

<div id="organization" itemscope itemtype="http://schema.org/Organization" itemref="employee-1"><span itemprop="name">Sun Industries</span>,<span itemprop="location" itemscope itemtype="http://schema.org/Place"><span itemprop="address" itemscope itemtype="http://schema.org/PostalAddress"><span itemprop="streetAddress">Technologies Street 42</span>,<span itemprop="addressLocality">Venustown</span><span itemprop="postalCode">98765</span></span></span>

<div id="employee-1" itemprop="employee" itemscope itemtype="http://schema.org/Person"><span itemprop="name">John Doe</span>,<span itemprop="jobTitle">销售经理</span>

给出以下内容:

组织itemType = http://schema.org/Organization员工人itemType = http://schema.org/Person姓名 = 约翰·多伊职位名称 = 销售经理名称 = 太阳工业地点地方itemType = http://schema.org/Place地址邮寄地址itemType = http://schema.org/PostalAddress街道地址 = 科技街 42addresslocality = 维纳斯镇邮政编码 = 98765

或者这个

<div id="employee-1" itemscope itemtype="http://schema.org/Person"><span itemprop="name">John Doe</span>,<span itemprop="jobTitle">销售经理</span><meta itemprop="worksFor" itemscope itemtype="http://schema.org/Organization" itemref="organization">

<div id="组织"><span itemprop="name">Sun Industries</span>,<span itemprop="location" itemscope itemtype="http://schema.org/Place"><span itemprop="address" itemscope itemtype="http://schema.org/PostalAddress"><span itemprop="streetAddress">Technologies Street 42</span>,<span itemprop="addressLocality">Venustown</span><span itemprop="postalCode">98765</span></span></span>

结果是

人itemType = http://schema.org/Person姓名 = 约翰·多伊职位名称 = 销售经理效劳于组织itemType = http://schema.org/Organization名称 = 太阳工业地点地方itemType = http://schema.org/Place地址邮寄地址itemType = http://schema.org/PostalAddress街道地址 = 科技街 42addresslocality = 维纳斯镇邮政编码 = 98765

Spec 对使用 itemref 不是很清楚,但示例有帮助

<p id="a">姓名:<span itemprop="name">Amanda</span></p><div id="b" itemprop="band" itemscope itemref="c"></div><div id="c"><p>乐队:<span itemprop="name">爵士乐队</span></p><p>尺寸:<span itemprop="size">12</span>玩家

The website of an organization, say "Sun Industries", would like to add a list of employees. The address and contact information of the organization is already present at the webpage, but the list of employees would be somewhere else.

So we have

<div id="organization" itemscope itemtype="http://schema.org/Organization">
  <span itemprop="name">Sun Industries</span>,
  <span itemprop="location" itemscope itemtype="http://schema.org/Place">
    <span itemprop="address" itemscope itemtype="http://schema.org/PostalAddress">
      <span itemprop="streetAddress">Technologies Street 42</span>,
      <span itemprop="addressLocality">Venustown</span>
      <span itemprop="postalCode">98765</span>
    </span>
  </span>
</div>

and later on in the HTML5 code we will have

<div id="employee-1" itemscope itemtype="http://schema.org/Person">
  <span itemprop="name">John Doe</span>,
  <span itemprop="jobTitle">Sales Manager</span>
</div>

How do we link the two objects "organization" and "employee-1" together?

I tried to add the following child to the "employee-1" object

<meta itemprop="worksFor" itemscope itemtype="http://schema.org/Organization" itemref="organization">

but that did not work (at least not in Google's Structured Data Testing Tool).

How can I use the microdata property itemref correctly in this case?

Just to be clear, I also tried the following:

So

<div id="organization" itemprop="worksFor" itemscope itemtype="http://schema.org/Organization">
  <span itemprop="name">Sun Industries</span>,
  ...
</div>
...
<div id="employee-1" itemscope itemtype="http://schema.org/Person" itemref="organization">
  <span itemprop="name">John Doe</span>,
  <span itemprop="jobTitle">Sales Manager</span>
</div>

but that gave me a Warning: Page contains property "worksfor" which is not part of the schema. for the "organization" object.

解决方案

Well, actually your last code snippet looks fine. Maybe with Yandex Validator the output will be more clear

person
  itemType = http://schema.org/Person
  worksfor
    organization
      itemType = http://schema.org/Organization
      name = Sun Industries
  name = John Doe
  jobtitle = Sales Manager

Couple of other working examples.

<body>
  <div id="organization" itemscope itemtype="http://schema.org/Organization" itemref="employee-1">
    <span itemprop="name">Sun Industries</span>,
    <span itemprop="location" itemscope itemtype="http://schema.org/Place">
      <span itemprop="address" itemscope itemtype="http://schema.org/PostalAddress">
        <span itemprop="streetAddress">Technologies Street 42</span>,
        <span itemprop="addressLocality">Venustown</span>
        <span itemprop="postalCode">98765</span>
      </span>
    </span>
  </div>
  <div id="employee-1" itemprop="employee" itemscope itemtype="http://schema.org/Person">
    <span itemprop="name">John Doe</span>,
    <span itemprop="jobTitle">Sales Manager</span>
  </div>
</body>

Gives the following:

organization
  itemType = http://schema.org/Organization
  employee
    person
      itemType = http://schema.org/Person
      name = John Doe
      jobtitle = Sales Manager
  name = Sun Industries
  location
    place
      itemType = http://schema.org/Place
      address
        postaladdress
          itemType = http://schema.org/PostalAddress
          streetaddress = Technologies Street 42
          addresslocality = Venustown
          postalcode = 98765

Or this

<body>
  <div id="employee-1" itemscope itemtype="http://schema.org/Person">
    <span itemprop="name">John Doe</span>,
    <span itemprop="jobTitle">Sales Manager</span>
    <meta itemprop="worksFor" itemscope itemtype="http://schema.org/Organization"  itemref="organization">
  </div>
  <div id="organization">
    <span itemprop="name">Sun Industries</span>,
    <span itemprop="location" itemscope itemtype="http://schema.org/Place">
      <span itemprop="address" itemscope itemtype="http://schema.org/PostalAddress">
        <span itemprop="streetAddress">Technologies Street 42</span>,
        <span itemprop="addressLocality">Venustown</span>
        <span itemprop="postalCode">98765</span>
      </span>
    </span>
  </div>
</body>

That results in

person
  itemType = http://schema.org/Person
  name = John Doe
  jobtitle = Sales Manager
  worksfor
    organization
    itemType = http://schema.org/Organization
    name = Sun Industries
    location
      place      
        itemType = http://schema.org/Place
        address
          postaladdress
            itemType = http://schema.org/PostalAddress
            streetaddress = Technologies Street 42
            addresslocality = Venustown
            postalcode = 98765

Spec is not very clear about using itemref but example helps

<div itemscope id="amanda" itemref="a b"></div>
<p id="a">Name: <span itemprop="name">Amanda</span></p>
<div id="b" itemprop="band" itemscope itemref="c"></div>
<div id="c">
 <p>Band: <span itemprop="name">Jazz Band</span></p>
 <p>Size: <span itemprop="size">12</span> players</p>
</div>

这篇关于HTML5 微数据 - itemref 到另一个 itemscope(人为组织工作)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
前端开发最新文章
热门教程
热门工具
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆