Re: RDFa API comments from TimBL

On Tue, 05 Oct 2010 21:08:54 +0100
Nathan <nathan@webr3.org> wrote:

> indeed! don't have document.anything* on the server side or in other 
> languages though..

Why not? check.rdfa.info uses an XML DOM all over the place at the
server end, in Perl. Plenty of $document->getElementsById('#foo') sort
of stuff going on.

The RDFa API is mostly aimed at Javascript, and mostly in a browser
environment. If you're implementing it in another environment there is
always going to be the possibility that some things that need some
slight adjustments.

Whenever an API is defined for multiple languages, implementations of
that API are probably going to have to make some compromises in order
to actually work in their target language, and to behave in the way
that their users expect. For example, in XML::LibXML, a popular Perl
DOM implementation (though it's just a wrapper around a C library) some
DOM methods which are supposed to return NodeList objects can be called
in such a way that they'll return native Perl arrays - just because
Perl developers are more likely to be comfortable with them.

Looking at an example from the RDFa API, store.forEach is essentially
passed a function as its argument. In some languages, like Java or PHP,
functions aren't first-class objects; they can't be passed as
arguments. A PHP implementation of the RDFa API would instead probably
be passed the name of a callback function as a string; a Java one would
use whatever convoluted workaround is currently popular in that world,
probably involving a dummy class with just a single method.

If, in your language/environment, document.getItemBySubject is
unworkable or would be an unexpected way of doing things, then do it
differently, but note the difference in your documentation.

-- 
Toby A Inkster
<mailto:mail@tobyinkster.co.uk>
<http://tobyinkster.co.uk>

Received on Tuesday, 5 October 2010 22:27:24 UTC