I'm not going to try to explain RDF and/or RDFa here, but thought any poor suckers looking for RDFa examples might benefit from me posting what I finally worked out, with help from my colleague Rob. Namely, how to annotate an HTML ordered list (<ol>) with RDFa attributes; and how to put RDFa attributes onto form elements.
Here's the HTML page with RDFa embedded in it. What I'm representing here is a sequence of collections, and the individual collections within it:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Collections</title>
</head>
<body>
<h1>Collections</h1>
<form method="post" action="http://receptacular.org/collections">
<ol xmlns="http://www.w3.org/1999/xhtml" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:xsd="http://www.w3.org/2001/XMLSchema#" xmlns:rec="http://receptacular.org/schema#" typeof="rdf:Seq" about="http://receptacular.org/collections">
<li rel="rdf:_1" resource="http://receptacular.org/collections/1">
<span style="display:none;" rel="rdf:type" resource="http://receptacular.org/schema#Collection"></span>
<div class="collection-label" property="rdfs:label">Vague Collection</div>
<input type="checkbox" id="collections-1-hidden" property="rec:hidden" datatype="xsd:boolean" content="false"/>
<label for="collections-1-hidden">hidden</label>
<input type="checkbox" id="collections-1-defaultSearch" property="rec:defaultSearch" datatype="xsd:boolean" content="false"/>
<label for="collections-1-defaultSearch">use for searches</label>
</li>
<li rel="rdf:_2" resource="http://receptacular.org/collections/2">
<span style="display:none;" rel="rdf:type" resource="http://receptacular.org/schema#Collection"></span>
<div class="collection-label" property="rdfs:label">Archive Collection</div>
<input type="checkbox" id="collections-2-hidden" property="rec:hidden" datatype="xsd:boolean" content="false"/>
<label for="collections-2-hidden">hidden</label>
<input type="checkbox" id="collections-2-defaultSearch" property="rec:defaultSearch" datatype="xsd:boolean" content="false"/>
<label for="collections-2-defaultSearch">use for searches</label>
</li>
<li rel="rdf:_3" resource="http://receptacular.org/collections/3">
<span style="display:none;" rel="rdf:type" resource="http://receptacular.org/schema#Collection"></span>
<div class="collection-label" property="rdfs:label">Main Collection</div>
<input type="checkbox" id="collections-3-hidden" property="rec:hidden" datatype="xsd:boolean" content="true" checked="checked"/>
<label for="collections-3-hidden">hidden</label>
<input type="checkbox" id="collections-3-defaultSearch" property="rec:defaultSearch" datatype="xsd:boolean" content="true" checked="checked"/>
<label for="collections-3-defaultSearch">use for searches</label>
</li>
</ol>
<p>
<input type="button" value="Save" id="save-collections"/>
</p>
</form>
</body>
</html>
Available online here: http://receptacular.org/collections
Things of note:
To see the RDF which can be extracted from this page, you can use the W3C's RDFa Distiller. Here's the resulting RDF:
<?xml version="1.0" encoding="utf-8"?>
<rdf:RDF
xmlns:dist="http://www.w3.org/2007/08/pyRdfa/distiller#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:rec="http://receptacular.org/schema#"
xmlns:xhv="http://www.w3.org/1999/xhtml/vocab#"
xmlns:xml="http://www.w3.org/XML/1998/namespace"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
>
<rdf:Seq rdf:about="http://receptacular.org/collections">
<rdf:_1>
<rec:Collection rdf:about="http://receptacular.org/collections/1">
<rec:hidden rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">false</rec:hidden>
<rec:defaultSearch rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">false</rec:defaultSearch>
<rdfs:label>Vague Collection</rdfs:label>
</rec:Collection>
</rdf:_1>
<rdf:_2>
<rec:Collection rdf:about="http://receptacular.org/collections/2">
<rec:hidden rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">false</rec:hidden>
<rec:defaultSearch rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">false</rec:defaultSearch>
<rdfs:label>Archive Collection</rdfs:label>
</rec:Collection>
</rdf:_2>
<rdf:_3>
<rec:Collection rdf:about="http://receptacular.org/collections/3">
<rec:hidden rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">true</rec:hidden>
<rec:defaultSearch rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">true</rec:defaultSearch>
<rdfs:label>Main Collection</rdfs:label>
</rec:Collection>
</rdf:_3>
</rdf:Seq>
</rdf:RDF>
Saving changes to an RDFa-enabled form like this is another challenge, for which we used rdfquery, and RDF library for JQuery. (I recommend you use the latest svn HEAD version of this library, as older versions have a bug where they ignore RDFa elements nested inside elements without RDFa attributes.) Maybe I'll get round to that another time.
Comments
Thank you
i like JQuery :))