Data blocks, not marked up content

One of the use cases for both Microdata and RDFa (but not
microformats) is the exchange of data that is NOT displayed. Perhaps
they should not try and meet this use case. An example:

<div xmlns="http://www.w3.org/1999/xhtml"
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
  xmlns:gr="http://purl.org/goodrelations/v1#"
  xmlns:foaf="http://xmlns.com/foaf/0.1/"
  xmlns:vcard="http://www.w3.org/2006/vcard/ns#">

  <div typeof="gr:Location" about="#store">
    <div rev="gr:hasPOS" resource="#company"></div>
    <div property="gr:name" content="Hair Masters"></div>
    <div property="vcard:tel" content="707-829-2443"></div>
    <div rel="vcard:adr">
      <div typeof="vcard:Address">
        <div property="vcard:country-name" content="USA"></div>
        <div property="vcard:locality" content="Sebastpol"></div>
        <div property="vcard:postal-code" content="95472"></div>
        <div property="vcard:street-address" content="6980 Mckinley Ave"></div>
      </div>
    </div>
    <div rel="vcard:geo">
      <div>
        <div property="vcard:latitude" content="38.40323"
datatype="xsd:float"></div>
        <div property="vcard:longitude" content="-122.82459"
datatype="xsd:float"></div>
      </div>
    </div>
    <div rel="foaf:page" resource=""></div>
  </div>
</div>


The GoodRelations snippet generator creates these blocks. These blocks
pollute the DOM, create a mass of useless elements and encode simple
data in a complex serialization. HTML already has a way of placing
data blocks in-line, "The script element allows authors to include
dynamic script and data blocks in their documents". So what does it
look like to place a the same data into a data block rather then using
Microdata or RDFa?

<script type="text/turtle">
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix gr: <http://purl.org/goodrelations/v1#> .
@prefix vcard: <http://www.w3.org/2006/vcard/ns#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

<#company> gr:hasPOS <#store> .

<#store> a gr:Location;
    gr:name "Hair Masters";
    vcard:adr [ a vcard:Address;
            vcard:country-name "USA";
            vcard:locality "Sebastpol";
            vcard:postal-code "95472";
            vcard:street-address "6980 Mckinley Ave" ];
    vcard:geo [ vcard:latitude 38.40323;
            vcard:longitude -122.82459 ];
    vcard:tel "707-829-2443";
    foaf:page <> .
</script>

Benefits:

* VERY copy and paste-able
* Prefixes (which some consider complicated) are scoped only inside
the script tag. Do not "infect" DOM.
* DOM and display almost completely unchanged.
* No huge hidden blobs of elements
* Extension point for new serializations is Media Type!

Limitations:

* Access is limited to User Agents (or scripts) that understand the
"text/turtle" media type.
* Does not markup existing content structures, that is what we have
RDFa, Microdata and Microformats for.

Unknowns:
* Relationship (if any) between multiple data blocks on the same page

References:
Turtle in HTML http://dvcs.w3.org/hg/rdf/raw-file/default/rdf-turtle/index.html#in-html
HTML5 http://dev.w3.org/html5/spec/Overview.html#the-script-element

Received on Tuesday, 4 October 2011 19:29:18 UTC