我正在用Schema.org微数据标记一个网站,结果遇到了一个问题。我知道我可以定义一本书,然后它就是作者(我会用../而不是
http://schema.org/
用于空间):
<div itemscope itemtype="../Book">
<span itemprop="name">Charlie and the Chocolate Factory</span>
written by <span itemprop="author">Roald Dahl</span>
</div>
但我正在标记一个关于作者的页面,所以我想用一种方法列出他的书,并说所有这些文章都是他写的,而不需要一遍又一遍地列出他的名字:
<article itemscope itemtype="../Person" id="main">
<h1 itemprop="name">Roald Dahl</h1>
<p>His books included <span itemscope itemtype="../Book">Charlie and the
Chocolate Factory</span> and
<span itemscope itemtype="../Book">James and the Giant Peach</span></p>
</article>
有什么想法吗?只是把
itemref=“主要”
没有帮助(因为我试图给出一个特定的关系,作者的关系,而不仅仅是笼统地将这两件事联系起来)。空跨度元素有意义吗?:
<span itemscope itemtype="../Book">James and the Giant Peach
<span itemprop="author" itemref="main"></span></span>
更新
:我想我已经想清楚了,对于任何抬头看的人来说。您可以为itemscope定义一个itemprop,以便稍后与itemref一起使用。所以我认为答案是:
<article itemscope itemtype="../Person" itemprop="author" id="main">
<h1 itemprop="name">Roald Dahl</h1>
<p>His books included <span itemscope itemtype="../Book" itemref="main">Charlie
and the Chocolate Factory</span> and
<span itemscope itemtype="../Book" itemref="main">James and the Giant Peach</span>
</article>
不确定如果有不止一个itemprop我想链接回来,我会怎么做(Schema.org完全是双向关系,只定义了其中一种方式),但这解决了我的特殊问题。
更新2
:这已经解决了我以前的问题,但我现在无法将其嵌入任何其他项目范围。所以,我想把整件事标记为
文章
,我不能这样做:
<main itemscope itemtype="../Article">
<article itemscope itemtype="../Person" itemprop="author" id="main">
<h1 itemprop="name">Roald Dahl</h1>
....
</article></main>
现在我的itemprop=“author”破解也被分配到了顶级
文章
。现在我的代码告诉人们,罗尔德·达尔不仅写了所给的书,还写了这篇文章!
有什么建议可以解决这个问题,或者解决我最初的问题,但不会导致这个问题?