Getting Started‎ > ‎

Constructing A Changeset


Constructing a ChangeSet

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

Reification in RDF, is the construction of a resource to describe a triple. To reify a triple:

  1. Create a new Resource
  2. give it an rdf:type property of rdf:Statement
  3. give it an rdf:subject property, where the value is the subject of the triple
  4. give it an rdf:predicate property, where the value is the predicate of the triple
  5. 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 .

do:

	@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:subject <http://example.com/>
					rdf:predicate <http://purl.org/dc/elements/1.1/title>
					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

  1. 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.
  2. Construct a description of the resource as you would like it to be. Think of this as the after description.
  3. Parse both before and after into two sets of triples.
  4. Iterate over the before triples
    1. 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.
  5. Iterate over the after triples
    1. 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.
Comments