Correct way to use multiple itemtypes in Microdata

此生再无相见时 提交于 2020-01-09 11:22:37

问题


See http://microdatagenerator.org/ for example.

What is the standardized way of, for example, declaring that my page is about a LocalBusiness which is also an AutomotiveBusiness? And where is the standards document that specifies this definitively?


回答1:


The W3C Microdata specification (currently a Working Draft) says about the itemtype attribute:

The itemtype attribute, if specified, must have a value that is an unordered set of unique space-separated tokens that are case-sensitive, each of which is a valid absolute URL, and all of which are in the same vocabulary. The attribute's value must have at least one token.

Multiple types from the same vocabulary

So you can specify multiple item types in an itemtype attribute if they are all from the same vocabulary (e.g. Schema.org):

<article itemscope itemtype="http://schema.org/HotelRoom http://schema.org/Offer">
 <!-- an MTE (multi-typed entity) 
      with the types 'HotelRoom' and 'Offer' -->
</article>

In your case it would typically not be necessary to provide both types, as AutomotiveBusiness inherits from LocalBusiness (i.e., every AutomotiveBusiness is also a LocalBusiness).

Multiple types from different vocabularies

If you want to provide types from multiple vocabularies, you can use Schema.org’s additionalType property:

<article itemscope itemtype="http://schema.org/AutomotiveBusiness">
  <link itemprop="additionalType" href="http://www.productontology.org/id/Automobile_repair_shop" />
 <!-- an MTE (multi-typed entity) 
      with the Schema.org type 'AutomotiveBusiness' 
      an an additional PTO type 'Automobile_repair_shop' -->
</article>

Multiple items with the same itemid value

You can also provide separate items (each with its own itemscope) and give them the same itemid value, thereby conveying that they are about the same thing:

<div itemscope itemtype="http://schema.org/HotelRoom" itemid="/rooms/42#this">
</div>

<div itemscope itemtype="http://schema.org/Offer" itemid="/rooms/42#this">
</div>



回答2:


@unor is right. As of now, this is not possible with HTML5 Microdata to use itemtypes from different vocabs. There is a discussion however [1] on how to enable this.

[1] http://www.w3.org/wiki/WebSchemas/additionalTypeProposal



来源:https://stackoverflow.com/questions/17706481/correct-way-to-use-multiple-itemtypes-in-microdata

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!