property hooks for RDFa API

Hi,

One of the useful features of tabulator is property actions, the basic 
jist is that you can assign a callback to be executed whenever a certain 
predicate/property is encountered. This is especially useful for adding 
in smushing or basic inference/reasoning rules.

It would mean the addition of the following method to one either 
DataStore or DataContext - probably DataStore.

   void registerPredicateHook( string predicate, function callback );

where the callback would have a signature of:

   void function(RDFTriple triple, DataStore store);

Example uses would include transporting predicates and objects across to 
another subject when owl:sameAs is encountered; adding a single triple 
to the store to say :Bob a foaf:Person whenever foaf:knows is 
encountered, or to register a class handler which hooked in on rdf:type 
(thus allowing processing of (+inverse) functional properties.

If adding this, it may be worth adding advice to implementers that 
states: if triples already exists in the store when a new predicate hook 
is registered, then the callback must be called on all existing triples 
in the store which have said predicate. And likewise some info to users 
to make them aware of this - mentioning because this is probably 
expected functionality (and also a handy shortcut).

ps: as for the name of the method and precise details I don't mind, 
simply used whatever came to mind for the example.

Best,

Nathan

Received on Sunday, 5 September 2010 00:09:09 UTC