Shared publicly  - 
 
Things people get wrong in RDFa markup

Lately, I've been looking a lot of both RDFa and Microdata formatted HTML. There are a number of things that authors (even experts) regularly get wrong:

@src and @rel attributes create reverse relation

Having code such as the following:

<body about="">
<img src="image.jpg" rel="icon"/>
...
</body>

You'd think that this would indicate that the icon for the document is <image.jpg>, but it actually says <image.jpg> xhv:image <> . The why of this is lost in the haze of history, but people regularly get this wrong. To get what you need, consider something like the following markup:


<body about="">
<span rel="icon"><img src="image.jpg"/></span>
...
</body>
@rel and @typeof and/or @about shouldn't be on the same element

Another common mistake is format such as the following:

<body vocab="http://schema.org/" about="">
<div rel="mainContentOfPage" about="#me" typeof="Person">
<p>Name: <span property="name">Gregg Kellogg</span></p>
<p>Knows: <a href="http://greggkellogg.net/#me" rel="knows">Myself</a></p>
</div>
</body>

Placing @rel and @about or @typeof on the same element indicates that the @about/@typeof indicate the subject not the object of a relation. To get the desired effect, use @resource, however, this does not let you set the type of the object resource. Alternatively, use the following type of markup:


<body vocab="http://schema.org/" about="">
<div rel="mainContentOfPage"
<div about="#me" typeof="Person">
<p>Name: <span property="name">Gregg Kellogg</span></p>
<p>Knows: <a href="http://greggkellogg.net/#me" rel="knows">Myself</a></p>
</div>
</div>
</body>

Another area of common mis-understanding is that the document order of statements within an HTML document is not significant when creating a list of resources. Consider the following example from schema.org/MusicPlaylist:


<div itemscope itemtype="http://schema.org/MusicPlaylist">
<span itemprop="name">Classic Rock Playlist</span>
<meta itemprop="numTracks" content="5"/>

<div itemprop="tracks" itemscope itemtype="http://schema.org/MusicRecording">
1.<span itemprop="name">Sweet Home Alabama</span> -
<span itemprop="byArtist">Lynard Skynard</span>
</div>

<div itemprop="tracks" itemscope itemtype="http://schema.org/MusicRecording">
2.<span itemprop="name">Shook you all Night Long</span> -
<span itemprop="byArtist">AC/DC</span>
</div>

...
</div>

You would think that this describes a track ordering, but it does not (at least in RDF). Doing this requires RDF List constructs missing from both Microdata and RDFa. In Turtle, you could do it as follows:


@prefix:<http://schema.org/> .
[ a :MusicPlaylist;
:name "Classic Rock Playlist";
:numTracks 5;
:tracks (
[a :MusicRecording; :name "Sweet Home Alabama"; :byArtist "Lynard Skynard"]
[a :MusicRecording; :name "Shook you all Night Long"; :byArtist "AC/DC"]
...
)
]

It would seem obvious that an HTML ordered list could be used to generate an RDF List, but it received to achieve enough interest to make it through.These are just a couple of things that are confusing about RDFa, and offer good fodder for Microdata proponents to complain about the complexity of RDFa markup.

It's important to note that a core goal of RDFa 1.1 (http://www.w3.org/TR/rdfa-core/) is to be compatible with RDFa 1.0 (RDFa in XHTML), in which these decisions were established.

Perhaps a reconciliation between Microdata and RDFa could take the best of both:


* Craft RDF friendly URIs from terms (such as schema:Person above),* Reduce amount of document structure needed to describe common use cases,
* Better intuitive generation of RDF output,
* Ability to avoid RDF generation and go straight to JSON (perhaps JSON-LD),
* Use common URI prefixes,
* RDF Lists,
* Promote better HTML readability.

That's my 2 cents (for now)
Web Schema is a set of extensible schemas that enables webmasters to embed structured data on their web pages for use by search engines and other applications.
3
9
Michael Hausenblas's profile photoRobert Visser's profile photoMauro Toffanin's profile photoChris Chapman's profile photo
Add a comment...