Tim Berners-Lee wrote:
> I don't think they do.
> You have to figure out what you are going to pass.
> You have to allow someone to either use a prefixed URI or a full long URI or give a string or a number (or a Date).
> I've been writing lots of javascipt and I am happy to learn new tricks but I am sure that the
> user needs a consistent model and a simple compose-able rules.
>
>
> document.data.add(me, foaf('knows'), you);
> d = document.data
> d.add(me, foaf('name'), "John Doe");
> d.add(me, foaf('knows'), mydoc('sally');
> d.add(me, foaf('age'), 3);
> d.add(me, foaf('kidsAges'), [10, 6]); // Makes an RDF Collection
> d.add(me, foaf('dob'), new Date('1921-09-19')); // Makes the right datatype
>
> Where any of the three parameters to add can take any of the forms (modulo the RDF model).
> The aim is to coerce from the natural javascript to the appropriate RDF in a very consistent way.
Just a quick note to say that I've just released a library which handles
all of this:
https://github.com/webr3/js3
And it's completely RDFa API compatible so allows the above examples,
but also allows you to:
var me = {
name: "John Doe",
knows: sally,
age: 3
}.ref(':me');
and..
me.kidsAges = [10,6];
me.dob = new Date('1921-09-19');
where the js just /is/ rdf too, so you can then do:
me.n3() // dumps as n3/turtle
me.toNT() // dumps as nt
me.graphify() // dumps an RDFGraph for use w/ the RDFa API
Rather than converting, each value just is both js and rdf:
true.toNT(); //"true"^^<http://www.w3.org/2001/XMLSchema#boolean>
(12 * 1.4).toNT(); // "12.3"^^<http://www.w3.org/2001/XMLSchema#decimal>
Best,
Nathan