使用 GoodRelations 扩展 schema.org

Extending schema.org with GoodRelations

GoodRelations 网站简要介绍了 example 如何使用 GoodRelations 类 和属性扩展 schema.org。

不幸的是,使用 Google 结构化数据测试工具测试时示例标记无效。

对于作为示例给出的代码片段,"Offer" 类型无法识别属性 "hasBusinessFunciton" 和 "haspriceSpecification"。

 <div itemscope itemtype="http://schema.org/Offer" itemid="#offer">
  <div itemprop="name">Hepp Personal SCSI Controller Card</div>
  <div itemprop="description">The Hepp Personal SCSI is a 16-bit add-on card that allows attaching up to seven SCSI devices to your computer.</div>
      <link itemprop="http://purl.org/goodrelations/v1#hasBusinessFunction"
    href="http://purl.org/goodrelations/v1#Sell" />
    <!-- Shipment fees -->
  Delivery costs to
      <div itemscope itemprop="http://purl.org/goodrelations/v1#hasPriceSpecification"
   itemtype="http://purl.org/goodrelations/v1#DeliveryChargeSpecification">
    <meta itemprop="eligibleRegions" content="DE">Germany:
    <meta itemprop="hasCurrency" content="EUR">Euro:
    <span itemprop="hasCurrencyValue">10.00</span>
    <link itemprop="appliesToDeliveryMethod"
      href="http://purl.org/goodrelations/v1#UPS" />(via UPS)
  </div>
<!-- other offer properties follow here -->
...
</div>

是否有一些使用 GoodRelations 属性扩展的 schema.org 的工作示例?

在schema.org

中使用http://wiki.goodrelations-vocabulary.org/Cookbook/Vehicles怎么样

干杯

这个例子是有效的 Microdata,也适当地使用了 Schema.org 词汇。

Google’s Testing Tool 不是 验证者。它只根据 Google 自己的规则检查结构化数据,例如他们认识什么,或展示他们的 Rich Snippets。

此代码段发生了什么:两个属性(http://purl.org/goodrelations/v1#hasPriceSpecificationhttp://purl.org/goodrelations/v1#hasBusinessFunction)被指定为绝对 URL,这是四种有效方式之一 how to provide properties in Microdata.

但是,请注意微数据对混合词汇的支持有限。 RDFa 在这方面更强大。 (相关:differences between Microdata and RDFa。)

使用 RDFa,代码片段可能如下所示(保持相同 HTML):

<div typeof="schema:Offer" resource="#offer">

  <div property="schema:name">Hepp Personal SCSI Controller Card</div>
  <div property="schema:description">The Hepp Personal SCSI is …</div>
  <link property="gr:hasBusinessFunction" href="http://purl.org/goodrelations/v1#Sell" />

  Delivery costs to
  <div property="gr:hasPriceSpecification" typeof="gr:DeliveryChargeSpecification">
    <meta property="gr:eligibleRegions" content="DE" />Germany:
    <meta property="gr:hasCurrency" content="EUR" />Euro:
    <span property="gr:hasCurrencyValue">10.00</span>
    <link property="gr:appliesToDeliveryMethod" href="http://purl.org/goodrelations/v1#UPS" />(via UPS)
  </div>

</div>

(对 Schema.org 词汇表使用前缀 schema,对 RDFa Core Initial Context 中定义的 GoodRelations 词汇表使用 gr。)

原因是 GoodRelations 站点上的示例尚未更新以反映 GoodRelations 与 schema.org 的集成(只是因为我还没有设法做到这一点)。

为了理解这一点,您需要查看 GoodRelations 的历史:

http://wiki.goodrelations-vocabulary.org/History

GR 最初是一个独立的 Web 词汇表 ("ontology"),旨在用于 RDFa 或其他 RDF 语法(如 RDF/XML、Turtle 等)。

2009 年,雅虎开始在 RDFa 语法中采用 GoodRelations,2012 年 Google 紧随其后。请注意,这一切都发生在原始的 GoodRelations 命名空间中,即使用像

这样的标识符

http://purl.org/goodrelations/v1#BusinessEntity

2011年schema.org发布后,我与Google、Bing、雅虎合作,将GoodRelations整合到schema.org中,完成发布于2012.

这意味着(几乎)来自 GoodRelations 的任何元素现在也将成为 schema.org 的一部分。所以 GoodRelations 现在是 schema.org.

的官方扩展电子商务模型

结果是每个 GoodRelations 元素现在都有两个标识符:

a) 原来的,比如http://purl.org/goodrelations/v1#OpeningHoursSpecification

b) schema.org 中的一个,例如 http://schema.org/OpeningHoursSpecification

在某些情况下,原始 GoodRelations 命名空间和 schema.org 命名空间中派生版本的名称的本地部分不同,以便与 schema.org 中现有的命名约定保持一致],或者因为之前存在过类似的元素。

例如,一个"Offer"是

http://purl.org/goodrelations/v1#Offering

在原始的 GoodRelations 版本中,但是

http://schema.org/Offer 

在 schema.org。但两者是同一个概念元素。

有关命名差异的完整列表,请参阅

http://wiki.goodrelations-vocabulary.org/Cookbook/Schema.org#Naming_Differences

棘手的部分来了:

  1. GoodRelations 在 RDFa 语法的原始命名空间中得到 Google 和 Yahoo 的支持,但仅在 Microdata 或 JSON-LD 中的 schema.org 命名空间中,并且其原始命名空间中的支持可能有点过时了。

  2. 对于枚举(个人),原始命名空间仍然是官方命名空间,即来自 http://www.heppnetz.de/ontologies/goodrelations/v1.html#individuals remain valid in the http://purl.org/goodrelations/v1# ... namespace, e.g. http://purl.org/goodrelations/v1#Cash.

  3. 的所有元素

选择此选项是因为我们可以通过将值的标识符保留在原始命名空间中来减少 schema.org 的新元素数量。

因此,当您将 GoodRelations 用于搜索引擎时,您应该在 schema.org 命名空间中使用它。 http://purl.org/goodrelations/v1# ... 命名空间对基于 RDF/关联数据/SPARQL 的项目保持功能。

未来(可能是今年),GoodRelations 中的服务更新将提供

  • 更新示例以正确反映这一点并且
  • 映射公理,以便语义 Web 应用程序可以看到等价关系。

希望对您有所帮助!

祝福

马丁赫普 http://www.heppnetz.de