Choosing a Serialisation

From Schema Bib Extend Community Group

The Schema.org vocabulary has a primary purpose for embedding structured data within the HTML mark up of a web page. The search engine providers and core backers of of Schema.org (Google, Yahoo!, Bing, and Yandex) each will look for structured data in one of three serialisations - Microdata, RDFa, JSON-LD. Support for JSON-LD is fairly recent and may not yet be fully supported by search engines other than Google and/or their validation tools.

Which HTML based serialisation you use in your own implementation is mostly down to personal choice. Much of the Schema.org documentation references Microdata examples. This is a reflection of the fact that this was the first format supported. However it was soon followed by support for RDFa.

Enthusiastic supporters of Microdata and RDFa often have heated discussions about their various merits. In implementation terms, apart from Microdata being more complex for defining multiple Types, there is little to choose between them, as you will see from the examples below. It must be pointed out that the wider Linked Data community is based upon RDF and therefore more closely aligned with RDFa.

RDFa
<div vocab="http://schema.org/" typeof="Book" resource ="http://example.com/shop/item/1234">
    <span property="name">Dune</span>, 
    Author: <span property="author">Frank Herbert</span>
    ISBN: <span property="isbn">1439501661</span>
</div>
Microdata
<div itemscope itemtype="http://schema.org/Book" itemid="http://example.com/shop/item/1234">
    <span itemprop="name">Dune<span/>
    Author:<span itemprop="author">"Frank Herbert<span/>
    ISBN:<span itemprop="isbn">1439501661<span/>
 </div>
JSON-LD
<script type="application/ld+json">
{
  "@graph": [
    {
      "@id": "",
      "http://www.w3.org/ns/rdfa#usesVocabulary": {
        "@id": "http://schema.org/"
      }
    },
    {
      "@id": "http://example.com/shop/item/1234",
      "@type": "http://schema.org/Book",
      "http://schema.org/author": "Frank Herbert",
      "http://schema.org/isbn": "1439501661",
      "http://schema.org/name": "Dune"
    }
  ]
}
</script>

Schema.org in RDF

Although Schema.org is primarily a vocabulary for embedding structured data within the HTM mark up of a web page, it is equally applicable as a RDF vocabulary to be used in Linked Data. It is equally capable of being serialised in one of the several standard RDF serialisations (RDF/XML, Turtle, N-Triples, JSON-LD) separate from a HTML page situation. This separation is often useful to understand what is being described, without the clutter of HTM mark up cluttering the view. In several examples on this wiki a representation in Turtle is included to clarify the data description being proposed, separate from proposed HTML mark up in RDFa or Microdata.

Turtle
@prefix schema: <http://schema.org/> .
<http://example.com/shop/item/1234>
   rdf:type schema:Book;
   schema:name "Dune";
   schema:author "Frank Herbert";
   schema:isbn "123456677" .