Constructing a ChangeSet
A Changeset document is an RDF/XML document describing a ChangeSet resource, and reified rdf:Statements that the ChangeSet links to as candidates either for removal, or addition, to the store.
Reification in RDF, is the construction of a resource to describe a triple. To reify a triple:
- Create a new Resource
- give it an rdf:type property of rdf:Statement
- give it an rdf:subject property, where the value is the subject of the triple
- give it an rdf:predicate property, where the value is the predicate of the triple
- give it an rdf:object property, where the value is the object of the triple
eg: (in Turtle notation) to reify
<http://example.com/> <http://purl.org/dc/elements/1.1/title> "Anna Wilder's Homepage"@en .
@prefix: rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix cs:<http://purl.org/vocab/changeset/schema#> .
_:Statement_1 a rdf:Statement;
rdf:object "Anna Wilder's Homepage"@en .
Creating the ChangeSet
Required properties of the ChangeSet
The ChangeSet resource should have
In addition (if the ChangeSet is to have any affect on your data), it should have http://purl.org/vocab/changeset/schema#addition andhttp://purl.org/vocab/changeset/schema#removal properties pointing to the reified triples that are to be added or removed.
Working out which triples to add and remove
- Retrieve a Concise Bounded Description of the resource you want to change the description of. It should be the most current description of the resource; if you try to remove any properties of the resource that it does not have, the whole ChangeSet will fail (ChangeSets are atomic - they work or fail completely). Think of this as the beforedescription.
- Construct a description of the resource as you would like it to be. Think of this as the after description.
- Parse both before and after into two sets of triples.
- Iterate over the before triples
- For each before triple, look for an identical triple in the after set. If you don't find a match, reify that before triple as an rdf:Statement, and add that rdf:Statement as acs:removal to the ChangeSet.
- Iterate over the after triples
- For each after triple, look for an identical triple in the before set. If you don't find a match, reify that after triple as an rdf:Statement, and add that rdf:Statement as acs:addition to the ChangeSet.