html5 – microdata schema.org:如何混合模式?

你好我有一个页面( http://schema.org/WebPage),其中包含一个评论( http://schema.org/Review)

问题是:

>如何处理重复内容
是正确的制作元素属于两个或多个范围吗?
>怎么做,重复两次文本?
>或者我应该避免多个引用?

例:

<html itemscope itemtype="http://schema.org/WebPage">
    <Meta name="description" content="_________" itemprop="description">
    ...
    <div itemscope itemtype="http://schema.org/Review">
        <div itemprop="description">_________</div>
    </div>
    ...
</html>

该描述属于WebPage的审查AND,所以…在这种情况下应该写什么?

(注意:在前面的例子中,字符串“__”是相同的文本段落,重复两次)

编辑:

这可以解决吗? (html5规范没有说这个,但是定义了itemref属性)

<html itemscope itemtype="http://schema.org/WebPage" id="WEBPAGE">
    ...
    <div itemscope itemtype="http://schema.org/Review" id="REVIEW">
        <div itemprop="description" itemref="WEBPAGE REVIEW">_________</div>
    </div>
    ...
</html>

乐意改进问题!

解决方法

快速答案

>如何处理重复内容

>使用属性itemref

是正确的制作元素属于两个或多个范围吗?

>是的,这是你使用itemref for

>怎么做,重复两次文本?

>不,你只需要参考元素

>或者我应该避免多个引用?

>我没有看到任何不想使用多个引用的原因

一些例子

包装包装

当您使用itemref属性时,将refer元素中包含的所有属性都包含在不同的范围内.

<body itemscope itemtype="http://schema.org/WebPage" itemref="wrapper">
    ...
    <div itemscope itemtype="http://schema.org/Review">
        ...
        <div id="wrapper">
            <div itemprop="description">_________</div>

            <div itemprop="some-other-property">_________</div>
        </div>
        ...
    </div>
    ...
</body>

包装包装 – 一个不同的例子

让我们说你有一个产品在范围之外的几个不同的优惠.

<div itemscope itemtype="http://schema.org/Product" itemref="wrapper">
    ...
</div>

<div id="wrapper">
    <div itemprop="offers" itemscope itemtype="http://schema.org/Offer">
        ...
    </div>

    <div itemprop="offers" itemscope itemtype="http://schema.org/Offer">
        ...
    </div>

    <div itemprop="offers" itemscope itemtype="http://schema.org/Offer">
        ...
    </div>
</div>

包括一个特定的属性

您可能只希望在范围之外包含一个特定的属性,为此,我们可以直接在目标元素上直接设置id,并指定itemprop.

<body itemscope itemtype="http://schema.org/WebPage" itemref="target">
    ...
    <div itemscope itemtype="http://schema.org/Review">
        <div id="target" itemprop="description">_________</div>
    </div>
    ...
</body>

多重参考

也许包装器不适用,那么可以使用多个引用.你只需用空格分开它们.

<body itemscope itemtype="http://schema.org/WebPage" itemref="desc name">
    ...
    <div itemscope itemtype="http://schema.org/Review">
        <div id="desc" itemprop="description">_________</div>

        <div id="name" itemprop="name">_________</div>
    </div>
    ...
</body>

资源

另见其他的解释和例子:
http://www.w3.org/TR/2011/WD-microdata-20110405/
http://www.whatwg.org/specs/web-apps/current-work/multipage/microdata.html

相关文章

HTML5和CSS3实现3D展示商品信息的代码
利用HTML5中的Canvas绘制笑脸的代码
Html5剪切板功能的实现
如何通过HTML5触摸事件实现移动端简易进度条
Html5移动端获奖无缝滚动动画实现
关于HTML5和CSS3实现机器猫的代码