没有 itemprop 的嵌套微数据 itemscope [英] Nested microdata itemscope without itemprop
问题描述
对于我正在编写的微数据解析器,我解析了以下(简化的)html 源:
<头><meta itemprop="name" content="一些文章名称">头部><身体><div itemscope itemtype="http://schema.org/Movie"><span itemprop="name">Skyfall</span>
</html>
关于此的几个问题:
- 这是遵循 W3c 规范的有效实现吗?我在规范本身中找不到任何内容,但不知道它是否是一种常见模式.
- 我应该如何阅读这些微数据?我们是否正在处理包含电影的文章?或者有两个微数据项 - 一篇文章和一部电影?
任何帮助将不胜感激.
当提供 DOCTYPE 和缺失的 title
元素时,这是有效的 HTML5+Microdata.
您示例中的 Article
和 Movie
没有关系,因此这是两个单独的顶级项目:
文章name: "一些文章名称"电影名称:《天降》
项目仅通过 itemprop
相关联,而不是通过普通的 HTML 级嵌套.
例如,使用 about
属性,如下所示:
<h1 itemprop="name">一些文章名称</h1><div itemprop="about" itemscope itemtype="http://schema.org/Movie"><span itemprop="name">Skyfall</span>
会导致:
文章name: "一些文章名称"关于:电影名称:《天降》
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.
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"
这篇关于没有 itemprop 的嵌套微数据 itemscope的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!