Re: RDFa API - adding Namespace

Tim Berners-Lee wrote:
> On 2010-10 -11, at 20:23, Manu Sporny wrote:
>> var c = document.data.context.resolveCurie;
>> var t1 = data.createTriple(me, c('rdf:type'), c('foaf:Person') );
> 
> That will work.
> 
>> var t2 = data.createTriple(me, c('foaf:givenname') , myName );
>> var t3 = data.createTriple(me, c('foaf:homepage') , myHomepage );
> 
> No, this will not work.
> You must distinguish between a literal string "http://whatever" and a symbol <http://whatever>..

This natively will work because c (context.resolveCurie) returns an IRI 
/ symbol not a string.

It's also worth noting that c('foaf:name') may not resolve (if the 
prefix is unknown) whereas foaf('name') will always return the expected IRI.

>>>> In other words, creating an object just to create a CURIE
> 
> You are not creating a curie.
> RDF graphs don't have curies in them.
> You are creating an RDF node which has a URI.

I do have a general worry with regards curies which I've voiced 
previously, in that heavy usage of curies can lead to people thinking of 
  'foaf:name' as a globally unique name; whereas a namespace approach 
makes it clear that the URI is the globally unique name. Sometimes by 
trying to make things more simple you actually make them more complex.

> I wish we could write doSomething(foaf.name)
> That is nice Javascript.

If an API dereferenced the ontology then there's no reason why this 
couldn't be implemented, a Namespace() function would simply have to 
return an object rather than a function, saying that in javascript an 
object is a function so there's no reason it couldn't provide both options

   foaf = ns('http://...');
   foaf.name // would work
   foaf('name') // would work

>> I think the points above still stand, what do you think?
> 
> 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.

This certainly resonates with me, and I'm personally implementing this 
functionality on top of / in addition to the core RDF API.

In many ways it appears that other than the RDFa/document specific 
functionality, the core RDF API which we are creating is more of a 
standardized API of core functionality for library implementers, rather 
than an easy to use Javascript API for end users.

I do look forward to the day when we have that user friendly javascript 
api for rdf, and part of me feels it's a shame this isn't being produced 
where RDF/HTML/Javascript collide (RDFa), but over all I'm glad we're 
making progress towards that day.

Best,

Nathan

Received on Tuesday, 12 October 2010 09:31:51 UTC