Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
255 views
in Technique[技术] by (71.8m points)

microdata - Is 'itemprop' without parent 'itemscope' valid? Does it create an item?

In the following example, Microdata’s itemref attribute is used to add the email property to the Person item (both from a fictive Microdata vocabulary).

<body>

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

 <div id="orphan" itemprop="email">
   [email protected]
 </div>

</body>

Is this valid Microdata?

If I understand the "Associating names with items" algorithm correctly, the "itemrefed" properties are not moved but copied, which leaves this "orphan" itemprop without an item parent.

There are three valid cases for itemprop values. The following one seems to come closest:

If the item is not a typed item: a string that contains no "." (U+002E) characters and no ":" (U+003A) characters.

(Which would mean that the orphaned property is not a "defined property name", i.e., it doesn’t belong to the fictive vocabulary anymore (only the "copied" property does).)

But: there is no "item" involved, as there is no itemscope.

So you can’t specify itemprop without a parent itemscope at all? Doesn‘t seem so:

Every HTML element may have an itemprop attribute specified […]

What am I’m missing in the Microdata specification?

Does an itemprop without an itemscope parent create an item?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The spec requirement is just that the itemprop is used in at least one item. There's no suggestion that I can see that being referenced by an itemref does not constitute a usage, nor that the itemprop is copied, and that it is the copy which is used not the original. So I think the spec requirements are fulfilled, and the microdata is valid.

Moreover, consider the intent of the spec. The underlying idea is that an itemprop that is not used by any item is pointless - a waste of typing - an therefore must be an authoring mistake. That is sufficient for mark-up to be considered invalid. Since that is not the case here, there is no justification for making such a construct invalid.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...