Implementing "aboutEach" (ACTION JUN-01-01-#9)

Here's how Nokia's "Wilbur" RDF Toolkit implements "rdf:aboutEach":

The current (released) implementation is "unoptimized" and does not care
how much stuff it needs to keep around until each "aboutEach" has been
expanded. An optimized version is in the works, one that is somewhat
clever in deciding which triples to keep around.

The basic implementation works as follows:

1) When "aboutEach" is encountered, its "target" node (the one which is
the result of resolving the value of the "aboutEach" attribute) is
stored away (actually, pushed into the state stack of the parser's state
machine), and a temporary anonymous node is created.

2) The description is parsed normally, using the temporary node (just
created) as the subject for all the resulting statements.

3) The real "target node" is popped from the stack and it is verified
that it actually is an RDF container.

4) loop for triples x collected using the temporary node
     loop for triples y representing the elements of the target container
       add triple(y.object, x.predicate, x.object)
     end loop
     delete x
   end loop

As I said, this is "unoptimized". The next version provides some improvements:

a) Only keep around triples from containers.

b) If reasonably implementable (not of this sure yet), perform #4
piecewise within step #2 above.

This still does not take into account situations where the "aboutEach"
is encountered *before* the corresponding container, in which case we
still have to keep the temporary node and its triples around until the
container is parsed. It seems that depending on ordering of the
"aboutEach" vs. the container, triples resulting from one or the other
have to kept around for awhile to produce the correct result. We have
discussed adding a flag to Wilbur which would generate an error if
"aboutEach" is encountered, making sure you can run the parser in a
truly stream-based fashion.

Wilbur is available at http://purl.org/net/wilbur/

Regards,

	- Ora

-- 
Ora Lassila  mailto:daml@lassila.org  http://www.lassila.org/

Received on Thursday, 19 July 2001 15:58:38 UTC