SPARQL 1.1 Update @import url("local.css");
code { font-family: monospace; }
div.constraint, div.issue, div.note, div.notice { margin-left: 2em; }
ol.enumar { list-style-type: decimal; } ol.enumla { list-style-type: lower-alpha; } ol.enumlr { list-style-type: lower-roman; } ol.enumua { list-style-type: upper-alpha; } ol.enumur { list-style-type: upper-roman; }
div.exampleInner pre { margin-left: 1em; margin-top: 0em; margin-bottom: 0em} div.exampleOuter {border: 4px double gray; margin: 0em; padding: 0em} div.exampleInner { background-color: #d5dee3; border-top-width: 4px; border-top-style: double; border-top-color: #d3d3d3; border-bottom-width: 4px; border-bottom-style: double; border-bottom-color: #d3d3d3; padding: 4px; margin: 0em } div.exampleWrapper { margin: 4px } div.exampleHeader { font-weight: bold; margin: 4px}
em.rfc2119 { text-transform: lowercase; font-variant: small-caps; font-style: normal; } This version: http://www.w3.org/TR/2013/REC-sparql11-update-20130321/ Latest version: http://www.w3.org/TR/sparql11-update/ Previous version: http://www.w3.org/TR/2012/PR-sparql11-update-20121108/ Editors: Paula Gearon <[email protected]> Alexandre Passant, DERI Galway at the National University of Ireland, Galway, Ireland <[email protected]> Axel Polleres, Siemens AG <[email protected]> Please refer to the errata See also translations Copyright W3C ® MIT ERCIM Keio Beihang liability trademark document use This document describes SPARQL 1.1 Update, an update language for RDF graphs. It uses a syntax derived from the SPARQL Query Language for RDF. Update operations are performed on a collection of graphs in a Graph Store. Operations are provided to update, create, and remove RDF graphs in a Graph Store. May Be Superseded This section describes the status of this document at the time of its publication. Other documents may supersede this document. A list of current W3C publications and the latest revision of this technical report can be found in the W3C technical reports index Set of Documents This document is one of eleven SPARQL 1.1 Recommendations produced by the SPARQL Working Group SPARQL 1.1 Overview SPARQL 1.1 Query Language SPARQL 1.1 Update SPARQL1.1 Service Description SPARQL 1.1 Federated Query SPARQL 1.1 Query Results JSON Format SPARQL 1.1 Query Results CSV and TSV Formats SPARQL Query Results XML Format (Second Edition) SPARQL 1.1 Entailment Regimes SPARQL 1.1 Protocol SPARQL 1.1 Graph Store HTTP Protocol No Substantive Changes There have been no substantive changes to this document since the previous version change log color-coded diff Please Send Comments Please send any comments to [email protected] public archive SPARQL Working Group errata [email protected] public archive Endorsed By W3C This document has been reviewed by W3C Members, by software developers, and by other W3C groups and interested parties, and is endorsed by the Director as a W3C Recommendation. It is a stable document and may be used as reference material or cited from another document. W3C's role in making the Recommendation is to draw attention to the specification and to promote its widespread deployment. This enhances the functionality and interoperability of the Web. Patents This document was produced by a group operating under the 5 February 2004 W3C Patent Policy public list of any patent disclosures Essential Claim(s) section 6 of the W3C Patent Policy 1 Introduction Document Conventions Language Form Terminology The Graph Store Graph Store and SPARQL Query Services SPARQL 1.1 Update Services Entailment and Consistency SPARQL 1.1 Update Language Graph Update INSERT DATA DELETE DATA DELETE/INSERT DELETE (Informative) INSERT (Informative) DELETE WHERE LOAD CLEAR Graph Management CREATE DROP COPY MOVE ADD SPARQL Update Formal Model General Definitions Graph Store Abstract Update Operation Auxiliary Definitions Dataset-UNION Dataset-DIFF Dataset( QuadPattern, μ, DS, GS ) Dataset( QuadPattern, P, DS, GS ) Graph Update Operations Insert Data Operation Delete Data Operation Delete Insert Operation Load Operation Clear Operation Graph Management Operations Create Operation Drop Operation Mapping Update Requests to the Formal Model Conformance A Security Considerations (Informative) Internet Media Type, File Extension and Macintosh File Type SPARQL 1.1 Update Grammar References Normative References Other References SPARQL 1.1 Update is intended to be a standard language for specifying and executing updates to RDF graphs in a Graph Store. SPARQL 1.1 Update provides the following facilities: Insert triples into an RDF graph in the Graph Store. Delete triples from an RDF graph in the Graph Store. Load an RDF graph into the Graph Store. Clear an RDF graph in the Graph Store. Create a new RDF graph in a Graph Store. Drop an RDF graph from a Graph Store. Copy, move, or add the content of one RDF graph in the Graph Store to another. Perform a group of update operations as a single action. This document is particularly related to the following other specification documents: SPARQL 1.1 Query Language SPARQL 1.1 Graph Store HTTP Protocol SPARQL 1.1 Protocol for RDF SPARQL 1.1 Update is a companion language and envisaged to be used in conjunction with the SPARQL 1.1 Query language SPARQL 1.1 Query language The SPARQL 1.1 Graph Store HTTP Protocol The SPARQL 1.1 Protocol for RDF SPARQL query processing service SPARQL 1.1 Graph Store HTTP Protocol The operations in this document contain language forms describing their use. These are meant as illustrative forms of the formal grammar described in the SPARQL 1.1 Query Language forms are shown informally in this document as for instance: ( WITH IRIref DeleteClause InsertClause InsertClause USING NAMED IRIref WHERE GroupGraphPattern Unlike other forms of EBNF where square brackets denote optionality, here [] | () ? * + BOLD Italics SPARQL 1.1 Query Grammar Example update requests are shown as follows: PREFIX dc: <http://purl.org/dc/elements/1.1/> INSERT { <http://example/egbook> dc:title "This is an example title" } WHERE {} Note: PREFIX syntax for IRIs SPARQL1.1 Query Language Data is shown in Turtle syntax as follows: @prefix dc: <http://purl.org/dc/elements/1.1/> . @prefix : <http://example.org/books/> . :book0 dc:title "SPARQL Tutorial" . When this document uses the words MUST MUST NOT SHOULD SHOULD NOT MAY recommended RFC 2119 The following terms are also in use throughout this document: Operation Graph Store INSERT DELETE Request SPARQL 1.1 Protocol for RDF The following terms are also used in this document as defined in the SPARQL 1.1 Query Language: QuadPattern ConstructTriples GRAPH QuadData QuadPattern GroupGraphPattern A Graph Store is a mutable container of RDF graphs managed by a single service. Similar to an RDF Dataset SPARQL 1.1 Query Language default graph named graphs MAY MAY default graph MAY Unlike an RDF Dataset, named graphs can be added to or deleted from a Graph Store. A Graph Store needs not be authoritative for the graphs it contains. That means a Graph Store can keep local copies of RDF graphs defined elsewhere on the Web and modify those copies independently of the original graph. In the simple case where there is one unnamed graph and no named graphs, SPARQL 1.1 Update can be used as a graph update language (as opposed to a Graph Store update language). The information how a Graph Store is accessed is defined in the protocol and Graph Store protocol specs. A Graph Store is accessible by either an update service (cf. protocol) or via the Graph Store protocol (cf. Graph Store protocol). In either case the Graph Store is hidden behind the service, making it accessible via the URI of a SPARQL update service or via a URI that responds to the Graph Store protocol. A formal definition for Graph Stores and how SPARQL 1.1 Update affects them is described in the SPARQL 1.1 Update Formal Model section A service (often referred to by the informal term SPARQL endpoint update service MAY MAY MAY SPARQL 1.1 Update requests are sequences of operations. Each request SHOULD SERVICE In the case of two different update services, whose respective Graph Stores contain graphs with the same names, there is no presumption that the updates done through one service will be propagated to the other, as the stores are independent entities. The behaviour of these services with respect to each other (such as automatic synchronization after updates) is implementation dependent. If the store is capable of calculating entailed answers, see SPARQL 1.1 Entailment Regimes DELETE After an update request is completed, a store that performs consistency checking with respect to a particular entailment regime on its graphs MAY MAY Also of note is that some stores may be capable of performing entailments with respect to an ontology capable of higher level processing, such as RDFS or OWL. Updates may interact with these entailment regimes in these systems. SPARQL 1.1 Update supports two categories of update operations on a Graph Store: Graph Update - addition and removal of triples from some graphs within the Graph Store. Graph Management - creating and deletion of graphs within the Graph Store, as well as convenient shortcuts for graph update operations often used during graph management (to add, move, and copy graphs). A request is a sequence of operations and is terminated by EOF (End of File). Multiple operations are separated by a ';' (semicolon) character. A semicolon after the last operation in a request is optional. Implementations MUST Operations all result either in success failure failure MAY SPARQL 1.1 protocol failure MUST The formal semantics of the following operations is defined in Section 4 Graph update operations change existing graphs in the Graph Store but do not explicitly delete nor create them. Non-empty inserts into non-existing graphs will, however, implicitly SHOULD MUST MAY If a graph is created implicitly by an update operation, then the behavior of the Graph Store MUST SPARQL 1.1 Update provides these graph update operations: The INSERT DATA SHOULD MUST The DELETE DATA The fundamental pattern-based actions for graph updates are INSERT DELETE DELETE/INSERT INSERT DELETE INSERT DATA DELETE DATA INSERT DATA DELETE DATA DATA DELETE DATA INSERT DATA DELETE DATA grammar The LOAD The CLEAR The INSERT DATA INSERT DATA QuadData where QuadData TriplesTemplate GRAPH ( GRAPH VarOrIri TriplesTemplate Variables in QuadData INSERT DATA grammar INSERT DATA QuadData If no graph is described in the QuadData SHOULD MUST Note that a triple MAY INSERT DATA { GRAPH <g> {} } ... does not create <g> CREATE LOAD Example 1: This snippet describes two RDF triples to be inserted into the default graph of the Graph Store. PREFIX dc: <http://purl.org/dc/elements/1.1/> INSERT DATA { <http://example/book1> dc:title "A new book" ; dc:creator "A.N.Other" . } Data before: # Default graph Data after: # Default graph Example 2: http://example/bookStore PREFIX dc: <http://purl.org/dc/elements/1.1/> PREFIX ns: <http://example.org/ns#> INSERT DATA { GRAPH <http://example/bookStore> { <http://example/book1> ns:price 42 } } Data before: # Graph: http://example/bookStore Data after: # Graph: http://example/bookStore The DELETE DATA DELETE DATA QuadData QuadData INSERT DATA DELETE DATA grammar As with INSERT DATA DELETE DATA QuadData DELETE DATA DELETE/INSERT Note that the deletion of non-existing triples has no effect, i.e., triples in the QuadData QuadData Example 3: Removing triples from a graph PREFIX dc: <http://purl.org/dc/elements/1.1/>
DELETE DATA { <http://example/book2> dc:title "David Copperfield" ; dc:creator "Edmund Wells" . } Data before: # Default graph Data after: # Default graph Example 4: http://example/bookStore PREFIX dc: <http://purl.org/dc/elements/1.1/> DELETE DATA { GRAPH <http://example/bookStore> { <http://example/book1> dc:title "Fundamentals of Compiler Desing" } } ;
PREFIX dc: <http://purl.org/dc/elements/1.1/> INSERT DATA { GRAPH <http://example/bookStore> { <http://example/book1> dc:title "Fundamentals of Compiler Design" } } Data before: # Graph: http://example/bookStore Data after: # Graph: http://example/bookStore The DELETE/INSERT WHERE ( WITH IRIref DeleteClause InsertClause InsertClause USING ( NAMED )? IRIref WHERE GroupGraphPattern The DeleteClause InsertClause DeleteClause DELETE QuadPattern InsertClause INSERT QuadPattern This operation identifies data with the WHERE DELETE INSERT INSERT DELETE DELETE INSERT The WITH DELETE INSERT WHERE WHERE WITH QuadPattern DELETE INSERT GroupGraphPattern WHERE GRAPH Following the optional WITH INSERT DELETE WHERE DELETE INSERT If the DELETE INSERT INSERT DELETE DELETE INSERT The USING USING NAMED RDF Dataset WHERE FROM FROM NAMED RDF Datasets in the SPARQL 1.1 Query Language USING FROM DELETE FROM GroupGraphPattern WHERE USING USING NAMED The WITH WITH WHERE USING USING NAMED USING USING NAMED WITH WHERE The GroupGraphPattern WHERE SELECT * WHERE GroupGraphPattern DELETE INSERT Again, QuadPattern TriplesTemplate GRAPH GRAPH TripleTemplate GRAPH INSERT DELETE WITH WITH To illustrate the use of the WITH WITH <g1> DELETE { a b c } INSERT { x y z } WHERE { ... } is considered equivalent to: DELETE { GRAPH <g1> { a b c } } INSERT { GRAPH <g1> { x y z } } USING <g1> WHERE { ... } Note that explicit GRAPH WITH WITH GRAPH Deleting triples that are not present, or from a graph that is not present will have no effect and will result in success DELETE DELETE DeleteClause grammar If an operation tries to insert into a graph that does not exist, then that graph SHOULD MUST INSERT ... { GRAPH <g> {} } ... does not create <g>. If a user intends to create a graph regardless of the data to be inserted, then the graph management operations ( CREATE LOAD Blank nodes that appear in an INSERT CONSTRUCT WHERE Templates with Blank Nodes formal semantics of DELETE/INSERT WHERE Example 5: http://example/addresses PREFIX foaf: <http://xmlns.com/foaf/0.1/>
WITH <http://example/addresses> DELETE { ?person foaf:givenName 'Bill' } INSERT { ?person foaf:givenName 'William' } WHERE { ?person foaf:givenName 'Bill' } Data before: # Graph: http://example/addresses Data after: # Graph: http://example/addresses ( WITH IRIref DELETE QuadPattern USING ( NAMED )? IRIref WHERE GroupGraphPattern The DELETE DELETE/INSERT INSERT DELETE/INSERT DELETE DELETE/INSERT If any DELETE GRAPH WITH The WHERE GroupGraphPattern DELETE/INSERT Example 6: PREFIX dc: <http://purl.org/dc/elements/1.1/> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
DELETE { ?book ?p ?v } WHERE { ?book dc:date ?date . FILTER ( ?date > "1970-01-01T00:00:00-02:00"^^xsd:dateTime ) ?book ?p ?v } The pattern in WHERE DELETE Data before: # Default graph Data after: # Default graph Example 7: http://example/addresses WITH http://example/addresses WHERE PREFIX foaf: <http://xmlns.com/foaf/0.1/>
WITH <http://example/addresses> DELETE { ?person ?property ?value } WHERE { ?person ?property ?value ; foaf:givenName 'Fred' } Data before: # Graph: http://example/addresses Data after: # Graph: http://example/addresses Another example of DELETE final example INSERT DELETE ( WITH IRIref INSERT QuadPattern USING ( NAMED )? IRIref WHERE GroupGraphPattern The INSERT DELETE/INSERT DELETE DELETE/INSERT INSERT If the INSERT GRAPH WITH USING (NAMED) WHERE USING (NAMED) WHERE DELETE/INSERT If any instantiation arising from the solution sequence produces a triple containing an unbound variable or an illegal RDF construct, such as a literal in subject or predicate position, then that triple is not inserted. The template can contain triples with no variables (known as ground or explicit triples), and these will also be inserted, provided that the solution sequence is not empty. Example 8: PREFIX dc: <http://purl.org/dc/elements/1.1/> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
INSERT { GRAPH <http://example/bookStore2> { ?book ?p ?v } } WHERE { GRAPH <http://example/bookStore> { ?book dc:date ?date . FILTER ( ?date > "1970-01-01T00:00:00-02:00"^^xsd:dateTime ) ?book ?p ?v } } Data before: # Graph: http://example/bookStore # Graph: http://example/bookStore2 Data after: # Graph: http://example/bookStore # Graph: http://example/bookStore2 Example 9: PREFIX foaf: <http://xmlns.com/foaf/0.1/> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
INSERT { GRAPH <http://example/addresses> { ?person foaf:name ?name . ?person foaf:mbox ?email } } WHERE { GRAPH <http://example/people> { ?person foaf:name ?name . OPTIONAL { ?person foaf:mbox ?email } } } Data before: # Graph: http://example/people # Graph: http://example/addresses Data after: # Graph: http://example/people # Graph: http://example/addresses Example 10: PREFIX PREFIX dc: <http://purl.org/dc/elements/1.1/> PREFIX dcmitype: <http://purl.org/dc/dcmitype/> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
INSERT { GRAPH <http://example/bookStore2> { ?book ?p ?v } } WHERE { GRAPH <http://example/bookStore> { ?book dc:date ?date . FILTER ( ?date < "2000-01-01T00:00:00-02:00"^^xsd:dateTime ) ?book ?p ?v } } ;
WITH <http://example/bookStore> DELETE { ?book ?p ?v } WHERE { ?book dc:date ?date ; dc:type dcmitype:PhysicalObject . FILTER ( ?date < "2000-01-01T00:00:00-02:00"^^xsd:dateTime ) ?book ?p ?v } Data before: # Graph: http://example/bookStore # Graph: http://example/bookStore2 Data after: # Graph: http://example/bookStore # Graph: http://example/bookStore2 DELETE WHERE QuadPattern The DELETE WHERE DELETE/INSERT WHERE DELETE/INSERT The QuadPattern TripleTemplate QuadPattern GRAPH TripleTemplate GRAPH Example 11: PREFIX foaf: <http://xmlns.com/foaf/0.1/>
DELETE WHERE { ?person foaf:givenName 'Fred'; ?property ?value } Data before: # Default graph Data after: # Default graph Example 12: http://example.com/names http://example/addresses http://example.com/names http://example/addresses PREFIX foaf: <http://xmlns.com/foaf/0.1/>
DELETE WHERE { GRAPH <http://example.com/names> { ?person foaf:givenName 'Fred' ; ?property1 ?value1 } GRAPH <http://example.com/addresses> { ?person ?property2 ?value2 } } # Graph: http://example.com/names # Graph: http://example.com/addresses Data after: # Graph: http://example.com/names # Graph: http://example.com/addresses The LOAD SHOULD MUST LOAD SILENT IRIref_from INTO GRAPH IRIref_to IRIref_from http IRIref_to If no destination graph IRI ( IRIref_to In case no RDF data can be retrieved (as opposed to the empty graph being retrieved) from the IRI denoted by IRIref_from SHOULD SHOULD The CLEAR CLEAR SILENT GRAPH IRIref DEFAULT NAMED ALL Here, the DEFAULT NAMED ALL GRAPH IRIref MAY # Remove all triples from a specified graph. CLEAR GRAPH IRIref in principle has the same effect as: # Remove all triples from the graph named with the IRI denoted by IRIref DELETE GRAPH IRIref WHERE GRAPH IRIref Note: CLEAR DEFAULT If the store records the existence of empty graphs, then the SPARQL 1.1 Update service, by default, SHOULD failure SILENT Stores that do not record empty graphs will always return success Graph management operations allow creating, destroying, moving and copying named graphs in the Graph Store, or adding the contents of one graph to another. Operations for creation and destruction are not required to result in any actions, since Graph Stores are not required to record the existence of empty named graphs. The default graph in a Graph Store always exists. SPARQL 1.1 Update provides these graph management operations: The CREATE The DROP The COPY The MOVE The ADD This operation creates a graph in the Graph Store: CREATE SILENT GRAPH IRIref For stores that record empty graphs, this will create a new empty graph in the store with a name specified by the IRI. If the graph already exists, then a failure SHOULD SILENT failure MUST SILENT Stores that do not record empty named graphs will always return success DROP SILENT GRAPH IRIref DEFAULT NAMED ALL The DROP GRAPH IRIref DEFAULT NAMED ALL DEFAULT MUST DROP DEFAULT CLEAR DEFAULT If the store records the existence of empty graphs, then the SPARQL 1.1 Update service, by default, SHOULD failure SILENT Stores that do not record empty graphs will always return success The COPY COPY SILENT GRAPH IRIref_from DEFAULT TO GRAPH IRIref_to DEFAULT is similar in operation to: DROP SILENT GRAPH IRIref_to DEFAULT INSERT GRAPH IRIref_to { ?s ?p ?o } } WHERE GRAPH IRIref_from { ?s ?p ?o } } The difference between COPY DROP/INSERT COPY DROP/INSERT If the destination graph does not exist, it will be created. By default, the service MAY failure SILENT Example 13: COPY DEFAULT TO <http://example.org/named> Data before: # Default graph # Graph http://example.org/named Data after: # Default graph # Graph http://example.org/named Note that the original content in http://example.org/named COPY The MOVE MOVE SILENT GRAPH IRIref_from DEFAULT TO GRAPH IRIref_to DEFAULT is similar in operation to: DROP SILENT GRAPH IRIref_to DEFAULT INSERT GRAPH IRIref_to { ?s ?p ?o } } WHERE GRAPH IRIref_from { ?s ?p ?o } }; DROP GRAPH IRIref_from DEFAULT The difference between MOVE DROP/INSERT/DROP MOVE DROP/INSERT/DROP If the destination graph does not exist, it will be created. By default, the service MAY failure SILENT Example 14: MOVE DEFAULT TO <http://example.org/named> Data before: # Default graph # Graph http://example.org/named Data after: # Default graph # Graph http://example.org/named Note that the original content in http://example.org/named MOVE The ADD ADD SILENT GRAPH IRIref_from DEFAULT TO GRAPH IRIref_to DEFAULT is equivalent to: INSERT GRAPH IRIref_to { ?s ?p ?o } } WHERE GRAPH IRIref_from { ?s ?p ?o } } If the destination graph does not exist, it will be created. By default, the service MAY failure SILENT Example 15: ADD DEFAULT TO <http://example.org/named> Data before: # Default graph # Graph http://example.org/named Data after: # Default graph # Graph http://example.org/named This section formally defines the semantics of Update Operations by describing their effects in terms of transformations of the Graph Store. Definition: Graph Store A Graph Store GS is a mutable container of RDF graphs. It has one unnamed (default) slot and zero or more named slots. The unnamed slot holds an RDF graph; each named slot is a pair of a graph and an associated IRI. The Graph Store can be viewed as a mutable RDF Dataset. GS = {DG, (iri 1 1 n n where the default graph DG is the RDF graph associated with the unnamed slot n ≥ 0 and for each 1 ≤ i ≤ n, G i i all IRIs are distinct, i.e., i≠j implies iri i j Note: i i 1 1 n n Definition: Update Operation An Update Operation Op is an atomic operation that accepts some arguments Args and transforms a Graph Store GS to another Graph Store GS', denoted as Op(GS, Args) = GS' By 'atomic operation' we mean that the operation performs the described transformation of the Graph Store either completely or leaves the Graph Store unchanged, i.e., the result is either GS' or GS (in case of error). An Update Operation can create new slots and new RDF graphs, or can remove existing slots and the corresponding graphs. It can also alter the state of each slot individually. We will define the semantics of each concrete update operation in terms of concrete instances of this abstract update operation definition. In the following we present auxiliary functions and basic operations for creating the union, and difference of RDF Datasets Note: This basic operation creates the union of two RDF Datasets. Definition: Dataset-UNION Let DS={DG} union {(iri i i j j i j Dataset-UNION(DS, DS') = {DG union DG'} union {(iri, G) | iri in graphNames(DS) union graphNames(DS')} and G defined as G i i i G j j j G i j i j where union between graphs is defined as set-union of triples in those graphs. Note: X X 1 2 n 1 2 n This operation removes the triples of a given dataset from another dataset. Definition: Dataset-DIFF Let DS={DG} union {(iri i i j j i j Dataset-DIFF(DS, DS') = {DG minus DG'} union { (iri, G) | iri in graphNames(DS) }) and G defined as G i i i G i j i j where G i j QuadPattern The following auxiliary function constructs an RDF Dataset from a QuadPattern Let μ be a solution mapping i i USING [NAMED] For a QuadPattern '{}' Dataset( QuadPattern '{' TriplesTemplate '}' Dataset( QuadPattern valid RDF triples μ TriplesTemplate 'GRAPH' VarOrIri '{' TriplesTemplate '}' Dataset( QuadPattern VarOrIri VarOrIri G G μ TriplesTemplate '{' QuadPattern1 QuadPattern2 '}' Dataset( QuadPattern QuadPattern1 QuadPattern2 Here, sk μ TriplesTemplate TriplesTemplate The function sk μ treatment of blank nodes in CONSTRUCT SPARQL1.1 Query Language remarks on scoping of blank nodes within requests in the SPARQL grammar QuadPattern P The following auxiliary function constructs an RDF Dataset from a QuadPattern Let P i i Dataset( QuadPattern P QuadPattern eval' P i.e., the union over all μ such that μ is in the solutions of P Here, eval' eval SPARQL1.1 Query Language treatment of blank nodes in BGP matching for SPARQL1.1 Query scoping graph The definition of eval'() guarantees that co-referent blank nodes in DS are not "lost" during pattern evaluation, cf. Treatment of Blank Nodes SPARQL1.1 Query DELETE { ?S ?P ?O . } WHERE { ?S ?P ?O . FILTER ( isBlank(?S)) } Data before: # Default graph Data after: # Default graph Definition: Insert Data Operation A Insert Data Operation QuadPattern OpInsertData(GS, QuadPattern QuadPattern where {} is the empty solution mapping. Definition: Delete Data Operation A Delete Data Operation QuadPattern OpDeleteData(GS, QuadPattern QuadPattern where {} is the empty solution mapping. Definition: Delete Insert Operation A Delete Insert Operation P QuadPattern QuadPattern DEL QuadPattern INS OpDeleteInsert(GS, DS, QuadPattern DEL QuadPattern INS P QuadPattern DEL P QuadPattern INS P Definition: Load Operation A Load Operation OpLoad(GS, documentIRI documentIRI OpLoad(GS, documentIRI iri iri documentIRI where graph( documentIRI documentIRI Definition: Clear Operation A Clear Operation def named all Let GS = {DG} union {(iri i i i OpClear(GS, iri) = GS if iri not in graphNames(GS); otherwise, OpClear(GS, iri j j j j j j j OpClear def i i OpClear named i OpClear all i Note: Drop Operation Definition: Create Operation A Create Operation Let GS = {DG} union {(iri i i i OpCreate(GS, iri) = GS union {(iri, {})} if iri not in graphNames(GS); otherwise, OpCreate(GS, iri) = GS Note: Drop Operation Definition: Drop Operation A Drop Operation i def def named all Let GS = {DG} union {(iri i i i OpDrop(GS, iri) = GS if iri not in graphNames(GS); otherwise, OpDrop(GS, iri j i i j OpDrop def def OpDrop named OpDrop all In this section we show how to map Update Requests in the SPARQL 1.1. Update Language to Update Operations over the Graph Store as defined earlier in this section. This mapping assumes that in all Update requests, any PREFIX WITH QuadPattern DELETE INSERT USING USING NAMED GroupGraphPattern WHERE GRAPH The mapping from requests to Update Operations is defined in terms of the recursive translation function Tr R R Update Operation COPY MOVE ADD Table 1: Mapping from Update Requests to Update Operations Update request R Tr R R 1 R 2 Tr Tr R 1 R 2 INSERT DATA QuadData OpInsertData QuadData DELETE DATA QuadData OpDeleteData QuadData DELETE QuadPattern DEL INSERT QuadPattern INS UsingClause WHERE GroupGraphPattern OpDeleteInsert Tr Dataset UsingClause QuadPattern DEL QuadPattern INS GroupGraphPattern DELETE QuadPattern DEL UsingClause WHERE GroupGraphPattern OpDeleteInsert Tr Dataset UsingClause QuadPattern DEL GroupGraphPattern INSERT QuadPattern INS UsingClause WHERE GroupGraphPattern OpDeleteInsert Tr Dataset UsingClause QuadPattern INS GroupGraphPattern DELETE WHERE QuadPattern OpDeleteInsert QuadPattern QuadPattern LOAD (SILENT)? IRIref OpLoad IRIref LOAD (SILENT)? IRIref from INTO GRAPH IRIref to OpLoad IRIref from IRIref to CLEAR (SILENT)? GRAPH IRIref OpClear IRIref CLEAR (SILENT)? DEFAULT OpClear def CLEAR (SILENT)? NAMED OpClear named CLEAR (SILENT)? ALL OpClear all CREATE (SILENT)? GRAPH IRIref OpCreate IRIref DROP (SILENT)? GRAPH IRIref OpDrop IRIref DROP (SILENT)? DEFAULT OpDrop def DROP (SILENT)? NAMED OpDrop named DROP (SILENT)? ALL OpDrop all This table uses one auxiliary translation function Tr Dataset USING USING NAMED Table 2: Mapping UsingClause Translation Function Definition Tr Dataset UsingClause the RDF Dataset DS described by the UsingClause the RDF Dataset corresponding to the current state of GS, otherwise Note: USING USING NAMED FROM FROM NAMED Specifying RDF Datasets See appendix B SPARQL 1.1 Update Grammar This specification is intended for use in conjunction with: the SPARQL 1.1 Graph Store HTTP Protocol SPARQL 1.1 Protocol for RDF Exposing RDF data for update creates many security issues which all deployments must be aware of, and consider the risks involved. This submission discusses some of the potential issues. New security problems are discovered regularly, and each implementation introduces its own concerns. Consequently implementers should be aware that this is only a partial list containing possible issues, and cannot be considered complete nor authoritative. Write access to data makes it inherently vulnerable to malicious access. Standard access and authentication techniques should be used in any networked environment. In particular, HTTPS should be used, especially when implementing the SPARQL HTTP-based protocols. (i.e., encryption with challenge/response based password presentation, encrypted session tokens, etc). Some of the weak points addressed by HTTPS are: authentication, active session integrity between client and server, preventing replays, preventing continuation of defunct sessions. SPARQL Update incurs all of the security concerns of SPARQL Query. In particular, stores which treat IRIs as dereferenceable need to protect against dereferenced IRIs from being used to invoke cross-site scripting attacks. Implementations will need to enforce their standard permissions scheme carefully. Permissions schemes always require careful design, and it is important to ensure that privileges in one area are not inadvertently applied to other parts of the system. Systems that provide both read-only and writable interfaces can be subject to injection attacks in the read-only interface. In particular, a SPARQL endpoint with a Query service should be careful of injection attacks aimed at interacting with an Update service on the same SPARQL endpoint. Like any client code, interaction between the query service and the update service should ensure correct escaping of strings provided by the user. While SPARQL Update and SPARQL Query are separate languages, some implementations may choose to offer both at the same SPARQL endpoint. In this case, it is important to consider that an Update operation may be obscured to masquerade as a query. For instance, a string of unicode escapes in a PREFIX clause could be used to hide an Update Operation. Therefore, simple syntactic tests are inadequate to determine if a string describes a query or an update. The Internet Media Type / MIME Type for the SPARQL Update Language is " application/sparql-update It is recommended that SPARQL Update files have the extension ".ru" (lowercase) on all platforms. It is recommended that SPARQL Update files stored on Macintosh HFS file systems be given a file type of "TEXT". Type name: application Subtype name: sparql-update Required parameters: None Optional parameters: None Encoding considerations: The syntax of the SPARQL Update Language is expressed over code points in Unicode [ UNICODE RFC3629 Unicode code points may also be expressed using an \uXXXX (U+0 to U+FFFF) or \UXXXXXXXX syntax (for U+10000 onwards) where X is a hexadecimal digit [0-9A-F] Security considerations: See SPARQL Update appendix A, Security Considerations RFC 3629 RFC3629 Interoperability considerations: There are no known interoperability issues. Published specification: This specification. Applications which use this media type: No known applications currently use this media type. Additional information: Magic number(s): A SPARQL query may have the string 'PREFIX' (case independent) near the beginning of the document. File extension(s): ".ru" Base IRI: The SPARQL 'BASE <IRIref>' term can change the current base IRI for relative IRIrefs in the query language that are used sequentially later in the document. Macintosh file type code(s): "TEXT" Person & email address to contact for further information: [email protected] Intended usage: COMMON Restrictions on usage: None Author/Change controller: The SPARQL 1.1 specification is a work product of the World Wide Web Consortium's SPARQL Working Group. The W3C has change control over these specifications. The formal definition for the SPARQL 1.1 Update grammar is provided with the SPARQL 1.1 Query grammar (Internet Assigned Numbers Authority) Official Names for Character Sets Internationalized Resource Identifiers (IRIs) RDF Semantics Latest version Aho, Alfred V., Ravi Sethi, and Jeffrey D. Ullman. Compilers: Principles, Techniques, and Tools Brüggemann-Klein, Anne. Formal Models in Document Processing Brüggemann-Klein, Anne, and Derick Wood. Deterministic Regular Languages One-Unambiguous Regular Languages James Clark. Comparison of SGML and XML (Internet Assigned Numbers Authority) Registry of Language Tags IETF (Internet Engineering Task Force). RFC 2141: URN Syntax IETF (Internet Engineering Task Force). RFC 3023: XML Media Types IETF (Internet Engineering Task Force). RFC 2781: UTF-16, an encoding of ISO 10646 IETF (Internet Engineering Task Force). RFC 3629: UTF-8, a transformation format of ISO 10646 (International Organization for Standardization). ISO 639:1988 (E). Code for the representation of names of languages. (International Organization for Standardization). ISO 3166-1:1997 (E). Codes for the representation of names of countries and their subdivisions — Part 1: Country codes ISO (International Organization for Standardization). ISO 8879:1986(E). Information processing — Text and Office Systems — Standard Generalized Markup Language (SGML). ISO (International Organization for Standardization). ISO/IEC 10744-1992 (E). Information technology — Hypermedia/Time-based Structuring Language (HyTime). Extended Facilities Annexe. The Unicode Consortium. The Unicode Standard, Version 5.0.0. ISO (International Organization for Standardization). ISO 8879:1986 TC2. Information technology — Document Description and Processing Languages Tim Bray, Dave Hollander, and Andrew Layman, editors. Namespaces in XML Change Log Changes since Proposed Recommendation Fixed a broken fragment link into SPARQL 1.1 Query Changes since Last Call Simplified explaining text as per the ban of shared bnodes across operations in a request. Editorial fix to Definition 4.2.3 and explaining remarks. Added explanation of QuadData to "Terminology" section. Added comment indicating that existing graphs do not lose triples during a LOAD Several minor editorial changes including the removal of "(non graph-aware)" since - essentially - every graph store is graph-aware. Changed SHOULD to MAY in 3.2.3 Copy Various editorial