Re: RDFa DOM API Editors Draft

On Mon, 2010-02-01 at 00:15 -0500, Manu Sporny wrote:
> http://dev.w3.org/rdfa/specs/rdfa-dom-api.html

I know this is just very early thoughts, but here's a few comments:

| interface Triple

Doesn't contain a mechanism to differentiate between these triples:

  <foo> ex:test <bar> .
  <foo> ex:test "bar" .

Perhaps a boolean attribute "is_literal"?

I'm assuming that the "_:" convention would be used to identify blank
nodes, but it is not clear whether an implementation of this API would
be required to keep blank node identifiers exactly how they are given in
the source RDFa or not. (RDF assigns no meaning to blank node
identifiers -- they're not part of the data; just part of the
serialisation. It seems unwise to rely on them being preserved by the
parser.) Of course, not all blank nodes have identifiers in the source
(some will be assigned during parsing due to chaining rules, etc).

| children of type array of Triple, readonly
| A list of triples that contain the same subject as this triple.

Not sure why this attribute is called "children". If a familial relation
is wanted, "siblings" seems more appropriate to me, as there's no
obvious hierarchy between triples.

Better would just be to have a document.getTriplesBySubject(s) method:

 // Instead of this_triple.children...
 document.getTriplesBySubject( this_triple.subject );

Even better, document.getTriplesByPattern(s, p, o):

 var triples = document.getTriplesByPattern(
  null,
  'http://xmlns.com/foaf/0.1/name',
  'Toby Inkster');

| getTriplesByType
| To perform a match, a direct string comparison is performed. If the 
| string comparison fails, the given type is checked against a subject's
| type starting at the last character in each string and moving
| backwards. 

This seems odd. I can see why it might be useful to return a list of
foaf:Persons when document.getTriplesByType('Person') is called; but I
can see less justification in allowing document.getTriplesByType('rson')
to work. Perhaps use word boundaries rather than character by character
scanning?

Also, what triples would be returned? Say the document contains only
three triples:

   <> foaf:primaryTopic <#me> .
   <#me> a foaf:Person .
   <#me> foaf:name "Toby Inkster" .

All of the triples contain the resource <#me> (in either subject or
object position), and <#me> is a Person, so would they all be returned?
Or would just the triples with <#me> as the subject be returned? Or just
the single triple "<#me> a foaf:Person"?

If the last of these is correct, then returning triples seems
superfluous, as you already know what the predicate will be, and have a
pretty good idea what the object will be. So getResourcesByType(t),
returning not triples, but a list of URIs and blank node identifiers
would be just as useful.

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

Received on Tuesday, 2 February 2010 10:05:35 UTC