Properties outside of 'itemscope' are assumed to belong to 'WebPage', but this creates invalid Microdata

StackOverflow https://stackoverflow.com/questions/22415921

  •  15-06-2023
  •  | 
  •  

Domanda

Microdata allows elements with itemprop but without parent itemscope, as long as they are referenced by an itemref somewhere on the page. (See my question Is 'itemprop' without parent 'itemscope' valid? Does it create an item?).

So this example should be valid:

<body>

 <div itemprop="email" id="orphan">
   alice@example.com
 </div>

 <div itemscope itemtype="http://example.org/Person" itemref="orphan">
   <span itemprop="name">Alice</span>
 </div>

</body>

Now, when someone is using the Schema.org vocabulary instead (replacing "example" with "schema" in the itemtype value), it’s my understanding that this example would no longer be valid, because on http://schema.org/WebPage it says:

Every web page is implicitly assumed to be declared to be of type WebPage, so the various properties about that webpage, such as breadcrumb may be used. We recommend explicit declaration if these properties are specified, but if they are found outside of an itemscope, they will be assumed to be about the page

So this would mean that the following items and name-value pairs would be created:

Item <http://schema.org/Person>
  name: Alice
  email: alice@example.com 

Item <http://schema.org/WebPage>
  email: alice@example.com

But http://schema.org/WebPage can’t have an email property, so this is invalid Microdata, as in this case the itemprop value has to be

[…] a defined property name allowed in this situation according to the specification that defines the relevant types for the item

So this statement on http://schema.org/WebPage, if respected by consumers and implementors, would result in invalid Microdata in cases where an element with itemprop has no itemscope parent and the property is not allowed on WebPage.

Is this correct or am I missing something?

How should I deal with this? Ignore this statement? AFAIK Microdata doesn’t require to follow those "informal rules", right?

È stato utile?

Soluzione

It's not often discussed in these terms, but validity is a relative concept. A document is valid or invalid only with respect to the requirements of a particular specification.

In this case, the microdata spec says nothing about WebPage, so the inclusion of the itemprop in an implicit WebPage item has no effect on the validity of your document with respect to the Microdata spec.

On the other hand, with respect to the schema.org WebPage spec, your document, or at least the WebPage item within it, would be invalid.

Whether this matters to you or not is your choice. There are really only two practical outcomes. A consumer of the microdata of your page can either create a WebPage item, or not create WebPage item. It is highly unlikely that a consumer would refuse to create a WebPage item because of the presence an additional out-of-schema itemprop, where it would have created the WebPage item otherwise.

And that's ultimately what validity is all about. It's there to establish a common language that producers and consumers of documents both understand. Providing that consumers understand the information that producers provide, technical violations of the validity rules of any particular specification are of little consequence.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top