Changesets
From n² wiki
Nearby: ChangeSet TroubleShooting, Metabox Changesets Collection, Changeset Protocol, Constructing_a_Changeset,Rolling_Back_Changesets
Changesets are a resource-oriented scheme for making updates to an RDF Graph. A Changeset has a single subject of change which refers to the resource being updated and a list of triples that should be removed or added from the graph. The triples are expressed as reified statements using the RDF reification vocabulary. A Changeset can only be applied if all the addition and removal triples share the same subject as the subject of change for the Changeset.
A Changeset can be thought of as the delta between two versions of a Concise Bounded Description of a resource. The delta is represented by the two sets of additions and removals triples. A ChangeSet can be used to modify the resource description by first removing all triples from the description that are in the removals set and adding the triples in the additions set.
The Talis Platform supports modification of graphs using the Changeset Protocol which uses HTTP to convey Changesets
The Changeset RDF vocabulary is defined by an RDF schema: http://purl.org/vocab/changeset
[edit] Changeset Basics
The following Changeset describes a change the the description of the resource identified by http://example.com/res#thing
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:cs="http://purl.org/vocab/changeset/schema#"> <cs:ChangeSet rdf:about="http://example.com/changesets#change"> <cs:subjectOfChange rdf:resource="http://example.com/res#thing"/> <cs:createdDate>2006-01-01T00:00:00Z</cs:createdDate> <cs:creatorName>Anne Onymous</cs:creatorName> <cs:changeReason>Change of title</cs:changeReason> <cs:removal> <rdf:Statement> <rdf:subject rdf:resource="http://example.com/res#thing"/> <rdf:predicate rdf:resource="http://purl.org/dc/elements/1.1/title"/> <rdf:object>Original Title</rdf:object> </rdf:Statement> </cs:removal> <cs:addition> <rdf:Statement> <rdf:subject rdf:resource="http://example.com/res#thing"/> <rdf:predicate rdf:resource="http://purl.org/dc/elements/1.1/title"/> <rdf:object>New Title</rdf:object> </rdf:Statement> </cs:addition> </cs:ChangeSet> </rdf:RDF>
The ChangeSet describes the removal of a single statement, the dc:title of the resource:
<http://example.com/res#thing> <http://purl.org/dc/elements/1.1/> "Original Title" .
And the subsequent addition of another statement with a new value for dc:title:
<http://example.com/res#thing> <http://purl.org/dc/elements/1.1/> "New Title" .
So, given the following description of the resource:
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/"> <rdf:Description rdf:about="http://example.com/res#thing"/> <dc:title>Original Title</dc:title> <dc:description>A short description of this resource</dc:description> </rdf:Description> </rdf:RDF>
Application of the ChangeSet would result in the following:
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/"> <rdf:Description rdf:about="http://example.com/res#thing"/> <dc:title>New Title</dc:title> <dc:description>A short description of this resource</dc:description> </rdf:Description> </rdf:RDF>
[edit] Linked ChangeSets
This example shows how a history of changes can be maintained using the precedingChangeSet property. We start with the resource description below:
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/"> <rdf:Description rdf:about="http://example.com/res#thing"/> <dc:title>Original Title</dc:title> <dc:description>A short description of this resource</dc:description> </rdf:Description> </rdf:RDF>
A change to the title of the resource is then made:
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/"> <rdf:Description rdf:about="http://example.com/res#thing"/> <dc:title>New Title</dc:title> <dc:description>A short description of this resource</dc:description> </rdf:Description> </rdf:RDF>
This change is modelled by a ChangeSet describing the removal of the existing dc:title triple and the addition of a new triple with a new value:
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:cs="http://purl.org/vocab/changeset/schema#"> <cs:ChangeSet rdf:about="http://example.com/res#change1"> <cs:subjectOfChange rdf:resource="http://example.com/res#thing"/> <cs:createdDate>2006-01-01T00:00:00Z</cs:createdDate> <cs:creatorName>Anne Onymous</cs:creatorName> <cs:changeReason>Change of title</cs:changeReason> <cs:removal> <rdf:Statement> <rdf:subject rdf:resource="http://example.com/res#thing"/> <rdf:predicate rdf:resource="http://purl.org/dc/elements/1.1/title"/> <rdf:object>Original Title</rdf:object> </rdf:Statement> </cs:removal> <cs:addition> <rdf:Statement> <rdf:subject rdf:resource="http://example.com/res#thing"/> <rdf:predicate rdf:resource="http://purl.org/dc/elements/1.1/title"/> <rdf:object>New Title</rdf:object> </rdf:Statement> </cs:addition> </cs:ChangeSet> </rdf:RDF>
Subsequently a dc:identifier property is added to the description:
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/"> <rdf:Description rdf:about="http://example.com/res#thing"/> <dc:title>New Title</dc:title> <dc:description>A short description of this resource</dc:description> <dc:identifier>Z875331</dc:identifier> </rdf:Description> </rdf:RDF>
The ChangeSet describes only the addition of the new statement. However this new ChangeSet uses the precedingChangeSet property to reference the first ChangeSet:
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:cs="http://purl.org/vocab/changeset/schema#"> <cs:ChangeSet rdf:about="http://example.com/res#change2"> <cs:precedingChangeSet rdf:resource="http://example.com/res#change1"/> <cs:subjectOfChange rdf:resource="http://example.com/res#thing"/> <cs:createdDate>2006-01-02T00:00:00Z</cs:createdDate> <cs:creatorName>Anne Onymous</cs:creatorName> <cs:changeReason>Addition of identifier</cs:changeReason> <cs:addition> <rdf:Statement> <rdf:subject rdf:resource="http://example.com/res#thing"/> <rdf:predicate rdf:resource="http://purl.org/dc/elements/1.1/identifier"/> <rdf:object>Z875331</rdf:object> </rdf:Statement> </cs:addition> </cs:ChangeSet> </rdf:RDF>
Later on the description is removed and a new ChangeSet is created to represent this change:
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/"> <rdf:Description rdf:about="http://example.com/res#thing"/> <dc:title>New Title</dc:title> <dc:identifier>Z875331</dc:identifier> </rdf:Description> </rdf:RDF>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:cs="http://purl.org/vocab/changeset/schema#"> <cs:ChangeSet rdf:about="http://example.com/res#change3"> <cs:precedingChangeSet rdf:resource="http://example.com/res#change2"/> <cs:subjectOfChange rdf:resource="http://example.com/res#thing"/> <cs:createdDate>2006-01-03T00:00:00Z</cs:createdDate> <cs:creatorName>Anne Onymous</cs:creatorName> <cs:changeReason>Removal of description</cs:changeReason> <cs:removal> <rdf:Statement> <rdf:subject rdf:resource="http://example.com/res#thing"/> <rdf:predicate rdf:resource="http://purl.org/dc/elements/1.1/description"/> <rdf:object>A short description of this resource</rdf:object> </rdf:Statement> </cs:removal> </cs:ChangeSet> </rdf:RDF>

