Wednesday, 15 August 2012

schema.org - How can I include an articleBody that is outside of the Article's itemscope? -



schema.org - How can I include an articleBody that is outside of the Article's itemscope? -

i attempting modify existing html include microdata using schema.org ontology.

due historic reasons, html not structured in proper hierarchy allow utilize of single itemscope. in example, articlebody separate name, author, , datepublished.

here simple snippet demonstrate illustration of problem , trying accomplish:

<html> <body> <div itemscope itemtype="http://schema.org/newsarticle"> <h1 itemprop="name">example news article page</h1> <span itemprop="datepublished">january 1, 2014</span> <span itemprop="author">john doe</span> </div> <div itemprop="articlebody"> <p> lorem ipsum </p> </div> </body> </html>

obviously, articlebody not contained within itemscope , hence parser have no clue fragment related to.

i attempted utilize itemref relate articlebody actual newsarticle.

<html> <body> <div itemscope itemtype="http://schema.org/newsarticle" id="myarticle"> <h1 itemprop="name">example news article page</h1> <span itemprop="datepublished">january 1, 2014</span> <span itemprop="author">john doe</span> </div> <div itemprop="articlebody" itemref="myarticle"> <p> lorem ipsum </p> </div> </body> </html>

this didn't appear work. modified utilize variations of adding itemscope, redeclaring itemtype, etc... unfortunately, none of methods seemed work. i'm assuming not right usage of itemref.

i made effort itemid. example:

<html> <body> <div itemscope itemtype="http://schema.org/newsarticle" itemid="foo"> <h1 itemprop="name">example news article page</h1> <span itemprop="datepublished">january 1, 2014</span> <span itemprop="author">john doe</span> </div> <div itemprop="articlebody" itemscope itemtype="http://schema.org/newsarticle" itemid="foo"> <p> lorem ipsum </p> </div> </body> </html>

again, didn't seem work. in both cases, google's structured info tester doesn't show expected results (the body either non-existent or not related article, itself) , yandex gives me error unable determine affiliation of these fields. there 2 possible reasons: fields incorrectly placed or orphan itemprop attribute indicated

i'm not quite sure if it's possible attempting accomplish. reason attempting things way have lot of pre-existing , complex html templates along massive amount of javascript. attempting refactor or otherwise modify existing html, aside adding annotations, become nightmare.

is possible attempting implement? if so, can show me simple code illustration or point out flaw in attempts?

thanks!

update

i got articlebody work using itemref. problem had using reference backwards -- referring newsarticle articlebody instead of other way around. here snippet:

<html> <body> <div itemref="content" id="articleheader" itemscope itemtype="http://schema.org/newsarticle"> <h1 itemprop="name">example news article page</h1> <span itemprop="author">john doe</span> </div> <div id="content" itemprop="articlebody"> <p> lorem ipsum blah blah blah </p> </div> </body> </html>

unfortunately, not appear scalable. let's want reference copyrightholder labeled in footer of page. if add together itemref article, appears blow , articlebody not related newsarticle. e.g.

<html> <body> <div itemref="content" itemref="company" id="articleheader" itemscope itemtype="http://schema.org/newsarticle"> <h1 itemprop="name">example news article page</h1> <span itemprop="author">john doe</span> </div> <div id="content" itemprop="articlebody"> <p> lorem ipsum blah blah blah </p> </div> <div id="company" itemprop="copyrightholder"> awesome company </div> </body> </html>

it appears on right track. problem had attempted declare itemref multiple times, each time id. according w3c, itemref expects space-separated list of id values.

here working example:

<html> <body> <div itemref="content company" id="articleheader" itemscope itemtype="http://schema.org/newsarticle"> <h1 itemprop="name">example news article page</h1> <span itemprop="author">john doe</span> </div> <div id="content" itemprop="articlebody"> <p> lorem ipsum blah blah blah </p> </div> <div id="company" itemprop="copyrightholder"> awesome company </div> </body> </html>

schema.org microdata

No comments:

Post a Comment