16.9.4. SPARQL Insert using LOAD
SPARQL INSERT operation can be done using the LOAD features:
SPARQL INSERT INTO <..> { .... } [[FROM ...] { ... }] SPARQL LOAD <x> [INTO <y>] -- <ResourceURL> will be the Graph IRI of the loaded data: SPARQL LOAD <ResourceURL>
Examples:
-
Load from ISQL:
SPARQL insert in graph <http://mygraph.com> { <http://example.com/dataspace/Kingsley#this> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://rdfs.org/sioc/ns#User> . <http://example.com/dataspace/Kingsley#this> <http://rdfs.org/sioc/ns#id> <Kingsley> . <http://example.com/dataspace/Caroline#this> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://rdfs.org/sioc/ns#User> . <http://example.com/dataspace/Caroline#this> <http://rdfs.org/sioc/ns#id> <Caroline> . <http://example.com/dataspace/Matt#this> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://rdfs.org/sioc/ns#User> . <http://example.com/dataspace/Matt#this> <http://rdfs.org/sioc/ns#id> <Matt> . <http://example.com/dataspace/demo#this> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://rdfs.org/sioc/ns#User> . <http://example.com/dataspace/demo#this> <http://rdfs.org/sioc/ns#id> <demo> .};
-
Load from .rq file:
-
Create DAV collection which is visible to public, for ex: http://example.com/DAV/tmp
-
Upload to the DAV collection the following file for ex. with name listall.rq and with the following content:
SPARQL PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX sioc: <http://rdfs.org/sioc/ns#> SELECT ?x ?p ?o FROM <http://mygraph.com> WHERE { ?x rdf:type sioc:User . ?x ?p ?o. ?x sioc:id ?id . FILTER REGEX(str(?id), "^King") } ORDER BY ?x
-
Execute from ISQL the following command:
SQL>SPARQL load bif:concat ("http://", bif:registry_get("URIQADefaultHost"), "/DAV/tmp/listall.rq") into graph <http://myNewGraph.com>;
As result should be shown:
callret-0 VARCHAR _______________________________________________________________________________ Load <http://example.com/DAV/tmp/listall.rq> into graph <http://myNewGraph.com> -- done 1 Rows. -- 321 msec.
-
-
Load from Resource URL:
SQL> SPARQL LOAD <http://www.w3.org/People/Berners-Lee/card#i>; callret-0 VARCHAR _______________________________________________________________________________ Load <http://www.w3.org/People/Berners-Lee/card#i> into graph <http://www.w3.org/People/Berners-Lee/card#i> -- done 1 Rows. -- 703 msec. SQL>