GoodRelations网站提供了关于如何使用GoodRelations类和属性扩展schema.org的简短example。
不幸的是,使用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
干杯
答案 0 :(得分:4)
原因是GoodRelations网站上的示例尚未更新以反映GoodRelations与schema.org的集成(仅仅因为我还没有设法做到这一点)。
为了理解这一点,您需要查看GoodRelations的历史记录:
http://wiki.goodrelations-vocabulary.org/History
GR最初是一个独立的Web词汇表(“本体”),旨在用于RDFa或其他RDF语法(如RDF / XML,Turtle,......)。
2009年,雅虎开始以RDFa语法表达GoodRelations,2012年谷歌紧随其后。请注意,这一切都发生在原始的GoodRelations名称空间中,即带有
之类的标识符http://purl.org/goodrelations/v1#BusinessEntity
在2011年发布schema.org之后,我与Google,Bing和Yahoo合作,将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中的现有命名约定保持一致,或者因为类似元素之前已存在。
例如,“优惠”是
http://purl.org/goodrelations/v1#Offering
在原始GoodRelations版本中,但
http://schema.org/Offer
schema.org中的。但这两者是相同的概念元素。
有关命名差异的完整列表,请参阅
http://wiki.goodrelations-vocabulary.org/Cookbook/Schema.org#Naming_Differences
现在有了棘手的部分:
Google和Yahoo在RDFa语法的原始名称空间中支持GoodRelations,但仅限于Microdata或JSON-LD中的schema.org名称空间,并且其原始名称空间中的支持可能有点过时
对于枚举(个体),原始命名空间仍然是官方命名空间,即http://www.heppnetz.de/ontologies/goodrelations/v1.html#individuals中的所有元素在http://purl.org/goodrelations/v1# ...命名空间中仍然有效,例如http://purl.org/goodrelations/v1#Cash
选择此选项是因为我们可以通过在原始命名空间中保留值的标识符来减少schema.org的新元素数量。
因此,当您将GoodRelations用于搜索引擎时,您应该在schema.org命名空间中使用它。 http://purl.org/goodrelations/v1# ...命名空间保持对基于RDF / Linked Data / SPARQL的项目起作用。
将来(可能是今年),将在GoodRelations中提供服务更新,这将提供
希望有所帮助!
祝福
Martin Hepp http://www.heppnetz.de
答案 1 :(得分:1)
此示例是有效的Microdata,也适用于Schema.org词汇表。
Google’s Testing Tool 不是验证者。它只根据Google自己的规则检查结构化数据,例如他们认识到什么,或者展示他们的Rich Snippets。
此代码段中发生了什么:两个属性(http://purl.org/goodrelations/v1#hasPriceSpecification
和http://purl.org/goodrelations/v1#hasBusinessFunction
)被指定为绝对网址,这是四种有效方式之一how to provide properties in Microdata。
但请注意,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
。)