ARQ - SPARQL Update

SPARQL Update is a W3C standard for an RDF update language with SPARQL syntax. It is described in "SPARQL 1.1 Update".

A SPARQL Update request is composed of a number of update operations, so in a single request graphs can be created, loaded with RDF data and modified.

Some examples of ARQ's SPARQL Update support are to be found in the download in src-examples/arq/examples/update.

The main important classes are:

  • GraphStoreFactory - A graph store is the container of graphs that is being updated. It can wrap RDF Datasets.
  • UpdateRequest - A list of Update to be performed.
  • UpdateFactory - Create UpdateRequest objects by poarsing strings or parsing the contents of a file.
  • UpdateAction - execute updates

To execute a SPARQL Update request as a script from a file:

Dataset ds = ...
GraphStore graphStore = GraphStoreFactory.create(ds) ;
UpdateAction.readExecute("update.ru", graphStore) ;

To execute a SPARQL Update request as a string:

Dataset ds = ...
GraphStore graphStore = GraphStoreFactory.create(ds) ;
UpdateAction.parseExecute(("DROP ALL", graphStore) ;

The application writer can create and execute operations:

UpdateRequest request = UpdateFactory.create() ;
request.add("DROP ALL")
       .add("CREATE GRAPH <http://example/g2>")
       .add("LOAD <file:etc/update-data.ttl> INTO <http://example/g2>") ;

// And perform the operations.
UpdateAction.execute(request, graphStore) ;

but be aware that each operation added needs to be a complete SPARQL Update operation, including prefixes if needed.

ARQ documentation index