问题
For a microdata parser I'm writing I parsed the following (simplified) html source:
<html itemscope itemtype="http://schema.org/Article" class="no-js" lang="nl">
<head>
<meta itemprop="name" content="Some article name">
</head>
<body>
<div itemscope itemtype="http://schema.org/Movie">
<span itemprop="name">Skyfall</span>
</div>
</body>
</html>
Couple of questions about this:
- Is this a valid implementation following the W3c spec? I couldn't find anything in the spec itself, but don't know if its a common pattern.
- How should I read this microdata? Are we dealing with an Article that contains a Movie? Or with two microdata items - an Article and a Movie?
Any help would be appreciated.
回答1:
When providing the DOCTYPE and the missing title
element, this is valid HTML5+Microdata.
The Article
and the Movie
in your example have no relation, so these are two separate top-level items:
Article
name: "Some article name"
Movie
name: "Skyfall"
Items are only related via itemprop
, not by plain HTML-level nesting.
For example, using the about property as in:
<div itemscope itemtype="http://schema.org/Article">
<h1 itemprop="name">Some article name</h1>
<div itemprop="about" itemscope itemtype="http://schema.org/Movie">
<span itemprop="name">Skyfall</span>
</div>
</div>
would result in:
Article
name: "Some article name"
about:
Movie
name: "Skyfall"
来源:https://stackoverflow.com/questions/33897007/nested-microdata-itemscope-without-itemprop