HTML5 Microdata - itemref到另一个项目范围(Person适用于组织) [英] HTML5 Microdata - itemref to another itemscope (Person works for Organization)

查看:115
本文介绍了HTML5 Microdata - itemref到另一个项目范围(Person适用于组织)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一家组织的网站称Sun Industries想要添加一份员工名单。组织的地址和联系信息已经出现在网页上,但员工名单会出现在其他地方。



所以我们有

 < div id =organizationitemscope itemtype =http://schema.org/Organization> 
< span itemprop =name> Sun Industries< / span> ;,
< span itemprop =locationitemscope itemtype =http://schema.org/Place>
< span itemprop =streetAddress>技术街道42< / span> ;,
< span itemprop =addressLocality> Venustown< / span>
< span itemprop =postalCode> 98765< / span>
< / span>
< / span>
< / div>

以后的HTML5代码中,我们会有

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



我们如何将两个对象organization和employee-1连接在一起?



我试图将下面的子元素添加到employee-1对象中

 < meta itemprop =worksForitemscope itemtype =http://schema.org/Organizationitemref =organization> 

但没有奏效(至少在Google的结构化数据测试工具中没有)。



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



<




  • 添加 itemprop =worksFor将code> itemref =organization添加到employee对象中。

  • li>


因此

 < div id =organizationitemprop =worksForitemscope itemtype =http://schema.org/Organization> 
< span itemprop =name> Sun Industries< / span>,
...
< / div>
...
< div id =employee-1itemscope itemtype =http://schema.org/Personitemref =organization>
< span itemprop =name> John Doe< / span> ;,
< span itemprop =jobTitle>销售经理< / span>
< / div>

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

解决方案

代码片段看起来很好。
也许通过 Yandex Validator 输出将会更加清晰

  person 
itemType = http://schema.org/Person
作品
组织
itemType = http ://schema.org/Organization
name = Sun Industries
name = John Doe
jobtitle =销售经理

其他工作示例。

 < body> 
< div id =organizationitemscope itemtype =http://schema.org/Organizationitemref =employee-1>
< span itemprop =name> Sun Industries< / span> ;,
< span itemprop =locationitemscope itemtype =http://schema.org/Place>
< span itemprop =streetAddress>技术街道42< / span> ;,
< span itemprop =addressLocality> Venustown< / span>
< span itemprop =postalCode> 98765< / span>
< / span>
< / span>
< / div>
< div id =employee-1itemprop =employeeitemscope itemtype =http://schema.org/Person>
< span itemprop =name> John Doe< / span> ;,
< span itemprop =jobTitle>销售经理< / span>
< / div>
< / body>

给出以下内容:

  organization 
itemType = http://schema.org/Organization
employee
person
itemType = http://schema.org/Person
name = John Doe
jobtitle =销售经理
名称= Sun Industries
地点
地点
itemType = http://schema.org/Place
地址
postaladdress
itemType = http://schema.org/PostalAddress
streetaddress =技术街道42
addresslocality = Venustown
邮政编码= 98765

或者这个

  <身体GT; 
< div id =employee-1itemscope itemtype =http://schema.org/Person>
< span itemprop =name> John Doe< / span> ;,
< span itemprop =jobTitle>销售经理< / span>
< meta itemprop =worksForitemscope itemtype =http://schema.org/Organizationitemref =organization>
< / div>
< div id =organization>
< span itemprop =name> Sun Industries< / span> ;,
< span itemprop =locationitemscope itemtype =http://schema.org/Place>
< span itemprop =streetAddress>技术街道42< / span> ;,
< span itemprop =addressLocality> Venustown< / span>
< span itemprop =postalCode> 98765< / span>
< / span>
< / span>
< / div>
< / body>

这导致

  person 
itemType = http://schema.org/Person
name = John Doe
jobtitle =销售经理
工作单位
机构
itemType = http://schema.org/Organization
name = Sun Industries
位置
地方
itemType = http://schema.org/Place
地址
postaladdress
itemType = http://schema.org/PostalAddress
streetaddress =技术街道42
addresslocality = Venustown
邮政编码= 98765
code>

规格不是很清楚使用 itemref 但示例帮助

 < div itemscope id =amandaitemref =ab>< / div> 
< p id =a>名称:< span itemprop =name> Amanda< / span>< / p>
< div id =bitemprop =banditemscope itemref =c>< / div>
< div id =c>
< p> Band:< span itemprop =name> Jazz Band< / span>< / p>
< p>大小:< span itemprop =size> 12< / span>播放器和LT; / p为H.
< / div>


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:

  • Add itemprop="worksFor" to the "organization" object.
  • Add itemref="organization" to the "employee" object.

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 Microdata - itemref到另一个项目范围(Person适用于组织)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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