Re: Very early alpha state pure JavaScript implementation of the RDFa API draft spec released

Hi Thomas,

Great news!

Just a quick comment on your point about the namespace for the API.

The easiest way to cater for both JS and native implementations is to
do something like this:

  if (!document.data) {
    document.data = {
      ...
    };
  }

This is a common technique when adding cross-browser support for
standards such as DOM 2 Events, XML parsing, etc.

Like any other language, JavaScript has its idioms, so you're actually
much more likely to see this:

  document.data = document.data || {
    ...
  };

But either way it amounts to the same thing; if some particular
feature doesn't exist already then add it via JavaScript.

(An old article of mine delves into this subject: Ajax and Progressive
Browser Enhancement [1].)

Regards,

Mark

[1] <http://webbackplane.com/thought/pbe>

--
Mark Birbeck, webBackplane

mark.birbeck@webBackplane.com

http://webBackplane.com/mark-birbeck

webBackplane is a trading name of Backplane Ltd. (company number
05972288, registered office: 2nd Floor, 69/85 Tabernacle Street,
London, EC2A 4RR)



On Mon, Oct 4, 2010 at 10:00 PM, Thomas Steiner <tomac@google.com> wrote:
> Hi RDFa API Working Group,
>
> I have released a very early alpha state pure JavaScript
> implementation of the RDFa API draft spec. It has still many flaws,
> and I'd like to sit down with you guys in order to get some open
> questions sorted, but at this stage it's ("it" being my
> implementation) already usable enough to be the foundation for a
> Chrome extension [0]. Rather than calling document.* you call
> LinkedData.API.* (I've put the API in my own namespace to avoid
> confusion with potential native implementations, and yepp, I do vote
> for renaming the API). I have coded an extension around example 1.3
> from the current draft spec [1]. The whole magic happens in just two
> calls:
>
> LinkedData.API.data.context.setMapping(
>    'cc',
>    'http://creativecommons.org/ns#');
> LinkedData.API.getElementsByProperty('cc:license');
>
> The extension is more or less just a toy, but the provided JavaScript
> code should already be good enough to test the examples in the latest
> spec draft. The library is implemented using XPath and not at all
> intended to be fast, or elegant, and currently just supports RDFa and
> has many of the advanced API calls mocked out. I'm happy to keep
> improving the code if anyone is interested. Just let me know. Thanks!
>
> Cheers,
> Tom
>
> [0] http://bit.ly/rdfalaser
> [1] http://www.w3.org/TR/rdfa-api/#data-based-web-page-modification
>
> --
> Thomas Steiner, Research Scientist, Google Inc.
> http://blog.tomayac.com, http://twitter.com/tomayac
>
>

Received on Tuesday, 5 October 2010 09:50:31 UTC