Proposal for RDF mappings in core

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
You are viewing a wiki page. You are welcome to join the group and then edit it. Be bold!

Three key functions:

<?php
rdf_get_mapping
($bundle);  // @TODO this should be 'container' or something more generic than even bundle
?>

From rdf.api.php in the development bzr repository we get definitions for our two hook functions:

<?php
/**
* Allow modules to define their own RDF mappings.
*
* @return
*   An associative array of mappings. Most keys will be bundle names, but
*   mappings can also be defined for non-bundles.
*/
function hook_rdf_mapping() {
  return array(
   
'blog' => array(
     
'rdftype' => array('sioc:Item', 'foaf:Document'),
     
'title'   => array(
       
'property' => array('dc:title'),
      ),
     
'created' => array(
       
'property' => array('dc:created'),
       
'datatype' => 'xsd:dateTime',
       
'callback' => 'date_iso8601',
      ),
     
'changed' => array(
       
'property' => array('dc:modified'),
       
'datatype' => 'xsd:dateTime',
       
'callback' => 'date_iso8601',
      ),
     
'body'    => array(
       
'property' => array('content:encoded'),
      ),
     
'uid'     => array(
       
'property' => array('sioc:has_creator'),
      ),
     
'name'    => array(
       
'property' => array('foaf:name'),
      ),
    )
  );
}

/**
* Allow modules to override existing mappings.

* @param $mappings
*   An associative array of mappings
* @return
*   void
*
*/
function hook_rdf_mapping_alter(&$mapping) {
}
?>

See more examples in rdf_test.module.

RDFa output

We want to keep the RDFa mark up as little as possible in the HTML output. One first rule of thumb is to inject the typeof attribute on the resouce page only (node/3) as opposed to outputing it on instance listing pages like front page. On teaser mode, we only output the title property and the resource attribute

<?php
<div about="/node/5#this" id="node-5" class="node clearfix">
  <
h2 ><a property="dc:title" href="/d701/node/5">title of the article</a></h2>
  <
div property="content:encoded dc:description" class="content">
    <
p>The content of the page...</p>
  </
div>
</
div>
?>

Each Drupal instance (node, term, user) gets assigned a URI in the about attribute which is built by appending #this to the page url, for instance http:example.org/node/1#this. This could be changed later so that the fragment reflects the type of instance, but for now it ease the implementation.

Semantic Web

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: