RDF Collections
RDF defines a number of different collections. The following collections are supported by GFEAR.
rdf:List
When defined as an rdf:List
the language will create blank nodes with the required rdf:first
and rdf:rest
; where the rdf:rest
points to another blank node with a rdf:first
or to the rdf:nil
. The end of the list is defined by the rdf:rest
pointing to a rdf:nil
object.
rdf:Bag
, rdf:Seq
, or rdf:Alt
All these collection types are implemented in the same manner. When one of these are used, a blank node is added to the graph. The first item is related to the blank node with the rdf:_1
property, followed by rdf:_2
, and so on`.
Creating a collection
To create a collection, the create collection
statement is used. At a minimum, the statement must define the type of collection to use (rdf:List
, rdf:Bag
, rdf:Seq
, or rdf:Alt
).
create collection myProjects rdf:List;
Typed Collections
Collections can be typed using a Uri. When adding items to the collection the language will ensure that the rdf:a
of the item being added matches the defined type of the collection.
To create a collection with a specified type the following syntax is used:
create collection myProjects rdf:List of foaf:Project;