X1: Y=2 Z=3The RDF language defines many ways to express this relation, for instance:
<rdf:Bag Id="B1"> <li><X ID="X1"/> </rdf:Bag> <rdf:Description aboutEach="B1"> <Y>2</Y> <Z>3</Z> </rdf:Description>This permits greater flexibility but means an application scanning the RDF database needs a way to search for the valid relations. To find the above, the application may call
triples = DB->nodesWithAllPredicates(DB->nodesWithTypes(NULL, {'X'});
Triple
s to the database and take advantage of
The RDF database keeps track of the last generated id. A client
application adding triples may get ids assigned by the database via
the assignId
function.
This raises the issue of name collisions.
In the case of aboutEach and aboutEachPrefix, the subjects of the triples don't arrive at the same time as the predicates and objects. One way to handle this it to gather the predicates and objects related to a bag and cross them with the contents of the bag after parsing is complete.
Since the RDF database may be used in scenarios where the parsing is not completed before the triples are needed, I add triples to the database as soon as they can be known. It does not matter whether the Bag is defined before or after the aboutEach or aboutEachPrefix reference is made.
The RDF database keeps a list of Containers and
their bagIDs. If Bag B1
is defined with contents
L1
, L2
and L3
, the created the
Description with an aboutEach equal to
B1
will get a pointer to the container
B1
. As predicate/object pairs are added to the
Description, they are crossed (multiplied against) each of
the subjects in the container B1
so that there
is a triple for each combination of subject in the Bag and
predicate/object in the Description.
When the Description is created, it registers its aboutEach with the Rdf database. As each Bag that is created, it registers itself with the Rdf database and gets a list of "interested description"s. As each subject is added to the Bag, a triple is created for each combination of that subject with each of the predicate/object pairs in the list of "interested description"s.
If any subject are added to the Bag after the Description has registered its aboutEach, they are caught by the previous mechanism and triples are created for the new subjects with each of the predicate/objects stored in the Description.
Attributions are an experimental way to keep track of which triples are trusted and why they're trusted. The implementation is currently just a sketch.