2016-05-05 4 views
1

Можно ли использовать itemref для ссылки на более чем 1 itemcope. Вот сценарий:HTML5 Microdata - itemref для нескольких itemscope

У меня есть несколько сообщений в блогах на странице, в каждом блоге есть мета-информация о том же человеке и организации. Вместо того, чтобы включать всю метаинформацию для человека и организации в каждом сообщении в блоге, можно ли на эту информацию ссылаться? Я могу сделать это с одной ссылкой, например. человек:

<div id="person" itemscope itemprop="author" itemtype="http://schema.org/Person"> 
    <span itemprop="name">Joe Blogs</span> 
</div> 

<article itemscope itemtype="http://schema.org/BlogPosting" itemref="person"> 
    <a href="/" itemprop="mainEntityOfPage"><h1 itemprop="headline">Title</h1></a> 
    <time datetime="2016-01-01 12:00:00" itemprop="datePublished">1st Jan</time> 
    <time datetime="2016-01-02 12:00:00" itemprop="dateModified">2nd Jan</time> 

    <div itemprop="image" itemscope itemtype="https://schema.org/ImageObject"> 
    <img src="image.jpg"> 
    <meta itemprop="url" content="http://example.com/image.jpg"> 
    <meta itemprop="width" content="400"> 
    <meta itemprop="height" content="400"> 
    </div> 

    <div itemscope itemprop="publisher" itemtype="http://schema.org/Organization"> 
    <span itemprop="name">Organization</span> 
    <div itemprop="logo" itemscope itemtype="https://schema.org/ImageObject"> 
     <meta itemprop="url" content="http://example.com/image.jpg"> 
     <meta itemprop="width" content="600"> 
     <meta itemprop="height" content="60"> 
    </div> 
    </div> 
</article> 

<article itemscope itemtype="http://schema.org/BlogPosting" itemref="person"> 
    <a href="/" itemprop="mainEntityOfPage"><h1 itemprop="headline">Title</h1></a> 
    <time datetime="2016-01-01 12:00:00" itemprop="datePublished">1st Jan</time> 
    <time datetime="2016-01-02 12:00:00" itemprop="dateModified">2nd Jan</time> 

    <div itemprop="image" itemscope itemtype="https://schema.org/ImageObject"> 
    <img src="image.jpg"> 
    <meta itemprop="url" content="http://example.com/image.jpg"> 
    <meta itemprop="width" content="400"> 
    <meta itemprop="height" content="400"> 
    </div> 

    <div itemscope itemprop="publisher" itemtype="http://schema.org/Organization"> 
    <span itemprop="name">Organization</span> 
    <div itemprop="logo" itemscope itemtype="https://schema.org/ImageObject"> 
     <meta itemprop="url" content="http://example.com/image.jpg"> 
     <meta itemprop="width" content="600"> 
     <meta itemprop="height" content="60"> 
    </div> 
    </div> 
</article> 

Но не были в состоянии сделать это с 2 ссылки:

<div id="person" itemscope itemprop="author" itemtype="http://schema.org/Person"> 
    <span itemprop="name">Joe Blogs</span> 
</div> 

<div id="organization" itemscope itemprop="publisher" itemtype="http://schema.org/Organization"> 
    <span itemprop="name">Organization</span> 
    <div itemprop="logo" itemscope itemtype="https://schema.org/ImageObject"> 
    <meta itemprop="url" content="http://example.com/image.jpg"> 
    <meta itemprop="width" content="600"> 
    <meta itemprop="height" content="60"> 
    </div> 
</div> 

<article itemscope itemtype="http://schema.org/BlogPosting" itemref="person" itemref="organization"> 
    <a href="/" itemprop="mainEntityOfPage"><h1 itemprop="headline">Title</h1></a> 
    <time datetime="2016-01-01 12:00:00" itemprop="datePublished">1st Jan</time> 
    <time datetime="2016-01-02 12:00:00" itemprop="dateModified">2nd Jan</time> 

    <div itemprop="image" itemscope itemtype="https://schema.org/ImageObject"> 
    <img src="image.jpg"> 
    <meta itemprop="url" content="http://example.com/image.jpg"> 
    <meta itemprop="width" content="400"> 
    <meta itemprop="height" content="400"> 
    </div> 
</article> 

<article itemscope itemtype="http://schema.org/BlogPosting" itemref="person" itemref="organization"> 
    <a href="/" itemprop="mainEntityOfPage"><h1 itemprop="headline">Title</h1></a> 
    <time datetime="2016-01-01 12:00:00" itemprop="datePublished">1st Jan</time> 
    <time datetime="2016-01-02 12:00:00" itemprop="dateModified">2nd Jan</time> 

    <div itemprop="image" itemscope itemtype="https://schema.org/ImageObject"> 
    <img src="image.jpg"> 
    <meta itemprop="url" content="http://example.com/image.jpg"> 
    <meta itemprop="width" content="400"> 
    <meta itemprop="height" content="400"> 
    </div> 
</article> 

Или:

<div id="person" itemscope itemprop="author" itemtype="http://schema.org/Person"> 
    <span itemprop="name">Joe Blogs</span> 
</div> 

<div id="organization" itemscope itemprop="publisher" itemtype="http://schema.org/Organization"> 
    <span itemprop="name">Organization</span> 
    <div itemprop="logo" itemscope itemtype="https://schema.org/ImageObject"> 
    <meta itemprop="url" content="http://example.com/image.jpg"> 
    <meta itemprop="width" content="600"> 
    <meta itemprop="height" content="60"> 
    </div> 
</div> 

<article itemscope itemtype="http://schema.org/BlogPosting" itemref="person"> 
    <a href="/" itemprop="mainEntityOfPage"><h1 itemprop="headline">Title</h1></a> 
    <time datetime="2016-01-01 12:00:00" itemprop="datePublished">1st Jan</time> 
    <time datetime="2016-01-02 12:00:00" itemprop="dateModified">2nd Jan</time> 

    <div itemprop="image" itemscope itemtype="https://schema.org/ImageObject"> 
    <img src="image.jpg"> 
    <meta itemprop="url" content="http://example.com/image.jpg"> 
    <meta itemprop="width" content="400"> 
    <meta itemprop="height" content="400"> 
    </div> 

    <meta itemref="organization" itemscope itemprop="publisher" itemtype="http://schema.org/Organization"> 
</article> 

<article itemscope itemtype="http://schema.org/BlogPosting" itemref="person"> 
    <a href="/" itemprop="mainEntityOfPage"><h1 itemprop="headline">Title</h1></a> 
    <time datetime="2016-01-01 12:00:00" itemprop="datePublished">1st Jan</time> 
    <time datetime="2016-01-02 12:00:00" itemprop="dateModified">2nd Jan</time> 

    <div itemprop="image" itemscope itemtype="https://schema.org/ImageObject"> 
    <img src="image.jpg"> 
    <meta itemprop="url" content="http://example.com/image.jpg"> 
    <meta itemprop="width" content="400"> 
    <meta itemprop="height" content="400"> 
    </div> 

    <meta itemref="organization" itemscope itemprop="publisher" itemtype="http://schema.org/Organization"> 
</article> 

Запуск обоих из них через https://developers.google.com/structured-data/testing-tool/ дает ошибки. Хотя, по крайней мере, третий пример показывает, что делается ссылка на организацию.

ответ

0

Атрибут itemref может принимать несколько значений, разделенных пробелом.

Таким образом, вместо

<article itemscope itemtype="http://schema.org/BlogPosting" itemref="person" itemref="organization"> 

использование

<article itemscope itemtype="http://schema.org/BlogPosting" itemref="person organization"> 

¹ исх. WHATWG spec: itemref/W3C Note: itemref

+0

Отлично, спасибо. –

Смежные вопросы