- From: Nathan <nathan@webr3.org>
- Date: Sat, 09 Oct 2010 18:44:16 +0100
- To: Tim Berners-Lee <timbl@w3.org>
- CC: Ivan Herman <ivan@w3.org>, RDFA Working Group <public-rdfa-wg@w3.org>
Tim Berners-Lee wrote:
> The way the namespaces work I think is nice,
>
> You say foaf = $rdf.Namespace("http://....");
> data.add(me, foaf('name'), you);
>
> Now I'd make it "ns" rather than Namespace in the spirit of making it all fairly compact.
Tim, Mark, Ivan, All,
This is a "minimal change" proposal to add tabulators Namespace
functionality in to the RDFa API, together with the use-case which
hopefully warrants it's inclusion.
I propose we change the definition of DataContext setMapping to be:
interface DataContext {
CurieResolver setMapping (in DOMString prefix, in DOMString iri);
...
};
and add the following interface:
[NoInterfaceObject Callback]
interface CurieResolver {
IRI resolve (in DOMString curie);
};
This has minimal impact on the RDFa API but makes it much more usable,
usage is as follows:
var foaf = context.setMapping('foaf', 'http://xmlns.com/foaf/0.1/');
foaf('name'); // returns IRI('http://xmlns.com/foaf/0.1/name')
To illustrate how useful this is, here are two versions of the
javascript required to create the following triples:
:me a foaf:Person;
foaf:givenname "Nathan";
foaf:homepage <http://webr3.org/>;
foaf:knows :bob, :sue.
with this proposal:
var t1 = data.createTriple(me, rdf('type') , foaf('Person') );
var t2 = data.createTriple(me, foaf('givenname') , myName );
var t3 = data.createTriple(me, foaf('homepage') , myHomepage );
var t4 = data.createTriple(me, foaf('knows') , thisDoc('bob') );
var t5 = data.createTriple(me, foaf('knows') , thisDoc('sue') );
without the proposal (current API usage):
var t1 = data.createTriple(me, data.context.resolveCurie('rdf:type')
, data.context.resolveCurie('foaf:Person') );
var t2 = data.createTriple(me,
data.context.resolveCurie('foaf:givenname') , myName );
var t3 = data.createTriple(me,
data.context.resolveCurie('foaf:homepage') , myHomepage );
var t4 = data.createTriple(me,
data.context.resolveCurie('foaf:knows') ,
data.context.resolveCurie(':bob') );
var t5 = data.createTriple(me,
data.context.resolveCurie('foaf:knows') ,
data.context.resolveCurie(':sue') );
I sincerely hope that illustrates how beneficial this would be to add,
and as a bonus it keeps the entire API type safe with no additional
changes needed.
Best,
Nathan
ps: here's the snipped code which makes the above examples work (remove
the `var = thisDoc` etc for the usage without this change):
var thisDoc = data.context.setMapping( "" , "http://webr3.org/nathan#" );
var rdf = data.context.setMapping( "rdf" ,
"http://www.w3.org/1999/02/22-rdf-syntax-ns#" );
var foaf = data.context.setMapping( "foaf" ,
"http://xmlns.com/foaf/0.1/" );
var me = data.context.resolveCurie(':me');
var myName = data.createPlainLiteral("Nathan");
var myHomepage = data.createIRI("http://webr3.org/");
Received on Saturday, 9 October 2010 17:45:35 UTC