1

I'm tagging a site with Schema.org microdata, and have run into a quandry. I understand that I can define a book and then it's author (I'll use ../ rather than http://schema.org/ for space):

<div itemscope itemtype="../Book">
<span itemprop="name">Charlie and the Chocolate Factory</span>
written by <span itemprop="author">Roald Dahl</span>
</div>

But I'm tagging a page about the author, so I want a way to list his books and say that all these items are written by him, without listing his name over and over again:

<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>

Any ideas? Just putting itemref="main" doesn't help (because I'm trying to give a specific relation, that of author, not just relate these two things generally). Does an empty span element make any sense?:

<span itemscope itemtype="../Book">James and the Giant Peach
<span itemprop="author" itemref="main"></span></span>

UPDATE: I think I've figured this one out, for anyone looking up. You can define an itemprop for an itemscope, to be used later with itemref. So I think the answer is:

<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>

Not sure what I'd do if there was more than one itemprop I wanted to link back (Schema.org is full on 2-way relationships with only one of those ways defined) but this solves my particular problem.

UPDATE2 : This has solved my previous problem, but I cannot now embed this within any other itemscopes. So, I want to tag the whole thing as an Article, I can't do it as:

<main itemscope itemtype="../Article">
<article itemscope itemtype="../Person" itemprop="author" id="main">
<h1 itemprop="name">Roald Dahl</h1>
....
</article></main>

Now my itemprop="author" hack is also assigned to the top level Article. Now my code is telling people that Roald Dahl wrote not only the books given, but this article itself!

Any suggestions how to solve this, or a solution to my original problem that doesn't cause this issue?

4

1 回答 1

0

考虑到您的问题,我想到了两个(都有些尴尬)的解决方案。分享我的想法。

所以回答你原来的问题。您可能会说您的_作者__并使用新的http://schema.org/WriteAction类。它的描述

创作书面创意内容的行为。

适合您的用例。实际上它在页面的示例中有所介绍。

然后我们可以这样做:

<main itemscope itemtype="http://schema.org/Article">
    <article  itemscope itemtype="http://schema.org/WriteAction">
        <div itemprop="agent" itemscope itemtype="http://schema.org/Person">
            <h1 itemprop="name">Roald Dahl</h1>
        </div>
        <p>His books included <span itemprop="result" itemscope itemtype="http://schema.org/Book"><span itemprop="name">Charlie and the Chocolate Factory</span></span> and 
        <span itemprop="result" itemscope itemtype="http://schema.org/Book"><span itemprop="name">James and the Giant Peach</span></span></p>
    </article>
</main>

接下来的想法是关于您更新的问题。除了在Article未涵盖的页面某处的不可见标签中复制部分数据外,我没有看到其他选项。但也许我错过了。例如,

<main itemscope itemtype="http://schema.org/Article">
    <article>
        <h1>Roald Dahl</h1>
        <p>His books included <span itemscope itemtype="http://schema.org/Book" itemref="main">
            <span itemprop="name">Charlie and the Chocolate Factory</span></span>
        and 
        <span itemscope itemtype="http://schema.org/Book" itemref="main">
            <span itemprop="name">James and the Giant Peach</span></span></p>
    </article>
</main>
<!-- in the footer or any other place -->
<div itemscope itemtype="http://schema.org/Person" itemprop="author" id="main">
    <meta itemprop="name" content="Roald Dahl"/>
</div>

两种解决方案都不是很好,但都有效。

于 2013-09-15T20:54:42.750 回答