W3C home > Mailing lists > Public > public-rdfa-wg@w3.org > October 2010

Re: RDFa API - adding Namespace

From: Nathan <nathan@webr3.org>
Date: Sat, 09 Oct 2010 19:02:03 +0100
Message-ID: <4CB0AE1B.2020808@webr3.org>
To: Mark Birbeck <mark.birbeck@webbackplane.com>
CC: Tim Berners-Lee <timbl@w3.org>, RDFA Working Group <public-rdfa-wg@w3.org>
Mark,

I forgot to (cc you in the original mail! and) note that this introduces 
zero dependencies on "Namespaces" in to the API and both the 
documentation examples and your code would be free to ignore it, in that 
people could use either style without anything breaking - similarly it 
allows "Namespaces" to be used anywhere an IRI is required (since it 
returns IRI) so the use-cases expand to any method which accepts an IRI.

Best,

Nathan

Nathan wrote:
> 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 18:10:02 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 17:05:21 UTC