W3C home > Mailing lists > Public > public-rdfa-wg@w3.org > January 2011

Re: PROPOSAL to close ISSUE-61: Does the RDFa API need a vocabulary helper

From: Nathan <nathan@webr3.org>
Date: Thu, 13 Jan 2011 09:38:07 +0000
Message-ID: <4D2EC7FF.1090205@webr3.org>
To: Manu Sporny <msporny@digitalbazaar.com>
CC: Ivan Herman <ivan@w3.org>, RDFa WG <public-rdfa-wg@w3.org>, Tim Berners-Lee <timbl@w3.org>
Manu Sporny wrote:
> On 01/03/2011 12:42 AM, Ivan Herman wrote:
>>> For example, the following is possible when using the RDF API:
>>> var rdf = document.data.rdf; rdf.prefixes.foaf =
>>> "http://xmlns.com/foaf/0.1/"; var foafname =
>>> rdf.resolve("foaf:name"); // at this point, foafname ==
>>> "http://xmlns.com/foaf/0.1/name"
>>> Given the code above, the following is also possible using the RDF
>>> API:
>>> var short = rdf.prefixes.shrink(foafname); // at this point short
>>> == "foaf:name"
>> The direct counterpart of the original issue/proposal would be to
>> have a definition of prefixes so that I could also say
>> var foafname = rdf.prefixes.foaf('name')
>> Ie, once I have defined the prefix I would not have to repeat it
>> verbatim because it becomes a function of its own right.
> Hmm, this is an interesting twist on what's in the spec right now and
> may address your request below, Ivan.

first, just a quick note that you can currently do:

   rdf.prefixes.foaf + 'name'

however, primarily if you want stable resolution in a modular 
environment then you just instantiate your own PrefixMap or Profile and 
use that in your script/lib/module

   x.foaf + 'name'

moving on to proposal below:

> I haven't tried this out, so there may be something preventing us from
> doing this in JavaScript, but basically, we'd change the PrefixMap
> interface from this:
> omittable getter DOMString get(in DOMString prefix);
> omittable setter void set(in DOMString prefix, in DOMString iri);
> to this (note the change in return type for get()):
> omittable getter PrefixResolver get(in DOMString prefix);
> omittable setter void set(in DOMString prefix, in DOMString iri);
> [Callback]
> interface PrefixResolver
> {
>    DOMString resolve(in DOMString prefix);
> }

sadly that's not possible, even with ECMAScript-262 v5 features, because 
of the setter, it would need to be a defined method such as setPrefix 
which would then define a magic property on the object to enable


However you'd need v5 advanced features and it's far from "normal" js 

That said, in a previous revision of the api, there was another 
(disputed iirc) approach, which was to change the return type of 
Profile::setPrefix from void to a "PrefixResolver", so you'd:

   foaf = rdf.setPrefix('foaf', 'http://xmlns.com/foaf/0.1/');

then you could do:

   rdf.prefixes.foaf + name

and you could still ignore this functionality and just do the 
getter/setter approach if you wanted:

   rdf.prefixes.foaf = 'http://xmlns.com/foaf/0.1/'
   rdf.prefixes.foaf + name

this is something of a happy medium which allows the compact functional 
style implemented in tabulator foaf('name'), and the current dictionary 
type approach.


Received on Thursday, 13 January 2011 09:40:11 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:19:50 UTC