« Open Web Platform Weekly Summary - 2011-11-14 - 2011-11-20 | Main | Open Web Platform Weekly Summary - 2011-11-21 - 2011-11-28 »

RDFa 1.1 meets JSON-LD in the Distiller…

I have blogged recently on the update of the RDFa 1.1 Distiller. I have just added a cool new feature. Up to today, the possible serializations were RDF/XML, Turtle, and N Triples. Although not yet final, I decided to add a JSON-LD serialization, too, in spite of the fact that JSON-LD is not yet final either (it is under development by a W3C Community Group). However, adding this to the system it shows the potentials of this combination…

An example may be the schema.org example I used in another blog lately:

<div vocab="http://schema.org/" typeof="Product">
  <img property="image" src="dell-30in-lcd.jpg" />
  <span property="name">Dell UltraSharp 30" LCD Monitor</span>

  <div property="aggregateRating" typeof="AggregateRating">
    <span property="ratingValue">87</span>
    out of <span property="bestRating">100</span>
    based on <span property="ratingCount">24</span> user ratings
  </div>

  <div property="offers" typeof="AggregateOffer">
	<span property="lowPrice">$1250</span>
	to <span property="highPrice">$1495</span>
	from <span property="offerCount">8</span> sellers
  </div>

  Sellers:
  <div property="offers" typeof="Offer" >
    <a property="url" href="save-a-lot-monitors.com/dell-30.html">
     Save A Lot Monitors - $1250</a>
  </div>
  
  <div property="offers" typeof="Offer">
    <a property="url" href="jondoe-gadgets.com/dell-30.html">
    Jon Doe's Gadgets - $1350</a>
  </div>
  ...
</div>     

Running this through the distiller, one gets the following JSON output:

{
    "@context": {
        "@vocab": "http://schema.org/",
        "@coerce": {
            "@iri": [
                "http://schema.org/image",
                "http://schema.org/offers",
                "http://schema.org/url",
                "http://schema.org/aggregateRating"
            ]
        }
    },
    "@type": "Product",
    "aggregateRating": {
        "@type": "AggregateRating",
        "ratingCount": "24",
        "ratingValue": "87",
        "bestRating": "100"
    },
    "offers": [
        {
            "@type": "Offer",
            "url": "http://www.example.org/save-a-lot-monitors.com/dell-30.html"
        },
        {
            "@type": "AggregateOffer",
            "lowPrice": "$1250",
            "highPrice": "$1495",
            "offerCount": "8"
        }
    ],
    "name": "Dell UltraSharp 30\" LCD Monitor",
    "image": "http://www.example.org/dell-30in-lcd.jpg"
}

Of course, the generated JSON may be a bit more complex, e.g., if the original page contains other RDFa attributes generating other triples. But it still looks pretty readable to me…

Filed by Ivan Herman on November 24, 2011 4:12 PM in HTML, Semantic Web, Technology, Tools
| | Comments (0) | TrackBacks (0)

Leave a comment

Note: this blog is intended to foster polite on-topic discussions. Comments failing these requirements and spam will not get published. Please, enter your real name and email address. Every individual comment is reviewed by the W3C staff. This may take some time, thank you for your patience.

You can use the following HTML markup (a href, b, i, br/, p, strong, em, ul, ol, li, blockquote, pre) and/or Markdown syntax.

Your comment


About you

This blog is written by W3C staff and working group participants,
 and maintained by Coralie Mercier.
Authorized parties may log in to create a new entry.
Powered by Movable Type, magpierss and a lot of Web Technology