gpt4 book ai didi

HTML5 微数据 - itemref 到另一个 itemscope(个人为组织工作)

转载 作者:技术小花猫 更新时间:2023-10-29 12:04:18 24 4
gpt4 key购买 nike

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

所以我们有

<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>

稍后在 HTML5 代码中我们将拥有

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

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

我尝试将以下 child 添加到“employee-1”对象

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

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

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

为了清楚起见,我还尝试了以下方法:

  • itemprop="worksFor" 添加到“组织”对象。
  • itemref="organization" 添加到“employee”对象。

所以

<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>

但这给了我一个警告:页面包含属性“worksfor”,它不是模式的一部分。“organization”对象。

最佳答案

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

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

几个其他的工作示例。

<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>

给出以下内容:

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

或者这个

<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>

结果是

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

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

<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(个人为组织工作),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17186058/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com