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

Reflections on the RDFa API

From: Niklas Lindström <lindstream@gmail.com>
Date: Thu, 14 Apr 2011 11:50:24 +0200
Message-ID: <BANLkTi=daZNYa0wjCS9aXcbWE3CZevyqwg@mail.gmail.com>
To: public-rdfa-wg <public-rdfa-wg@w3.org>
Hi all!

It is nice to see the progress on the RDF and RDFa APIs! I like that
PropertyGroup has been renamed, and e.g. the addition of getSubjects,
getProperties and getValues to DocumentData.

I have some suggestions for additions and improvements.

## Projections ##

I'd like to see Projection gain some methods to be able to traverse
the graph (entirely via Projections):

* getRel + retRels (or getProjection + getProjections)
* getRev + getRevs (or e.g. getSubjectProjection + getSubjectProjections)

An example of how usage would be like with these additions:

    var me = document.data.getProjection("http://example.org/me");
    var homepage = me.getRel("foaf:homepage");
    var title = homepage.get("dc:title");

Or one chained expression:

    var title =
data.getProjection("http://example.org/me").getRel("foaf:homepage").get("dc:title");

Work with my friends:

    me.getRels("foaf:knows").forEach(function (friend) {
        alert(friend.get("foaf:name"));
    });

Reverse relations (things created by me):

    var myCreations = me.getRevs("dct:creator");

The WebIDL for these would be something like:

    Projection    getRel (in DOMString uriOrCurie);
    Projection[]  getRels (in DOMString uriOrCurie);

    Projection    getRev (in DOMString uriOrCurie);
    Projection[]  getRevs (in DOMString uriOrCurie);

(I've mentioned these ideas before [1], [2].)

This resource-oriented way of working isn't uncommon in other RDF
API:s. Jena for instance has a Resource interface [3] reminiscent of
this. Recently, I've also added a new utility class in RDFLib [4]
which is inspired by both Jenas Resource and to some extent the RDFa
Projection. The discussion of this addition [5] explains some design
decisions and relations to e.g. RDF object mappers, etc.


## Literals with language ##

I also think that, since language tagged literals are converted to
plain strings when get/getAll is used, one should be able to provide a
language parameter to those methods. That would be used to filter out
only literals with the given language.

(Alternatives to that might be being able to pass language to the
getProjection(s) methods, next to (or as part of) the template
parameter. For comparison, in e.g. the Oort Python lib [6], I pass
language to a context, which is sort of like the Profile in the RDF
API. Language is also used in Gluon profiles [7] for this purpose
(predictable conversion of literals with language).)

Example:

    var title = homepage.get("dc:title", "en");


What do you think?

Best regards,
Niklas
--
<http://neverspace.net/>


[1]: http://lists.w3.org/Archives/Public/public-rdfa-wg/2010Jun/0046.html
[2]: http://lists.w3.org/Archives/Public/public-rdfa-wg/2010Nov/0078.html
[3]: http://www.openjena.org/tutorial/RDF_API/#ch-Navigating%20a%20Model
[4]: http://code.google.com/p/rdflib/source/browse/rdflib/description.py?r=feature%2Fresource-oriented-api
[5] http://code.google.com/p/rdflib/issues/detail?id=166
[6]: http://oort.to/
[7]: http://code.google.com/p/oort/wiki/Gluon#Compact_Profiles
Received on Thursday, 14 April 2011 09:51:13 UTC

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