- RDF Insert Methods in Virtuoso
- RDF Sink Folders (Virtuoso or ODS-Briefcase)
- HTTP Post using Content-Type: application/sparql-query
- Theory
- Simple Example 1
- Simple Example 2
- HTTP PUT
- Theory
- Simple Usage Example
- References
- SPARQL Insert using LOAD
- Theory
- Simple Example
- SPARQL Insert via /sparql endpoint
- Theory
- Simple Example
- References
- SPARQL Insert via HTTP Post using Content-Type: application/sparql-query and ODS wiki
- Theory
- Simple Example
- References
- (mount folder to DAV and dump; if this is the rdf_sink the Quad Store is updated automatically, or you can load from DAV manually to quad store)
- Theory
- Simple Example
- References
- Virtuoso Crawler (which includes the Sponger options so you crawl non-RDF but get RDF and this can go to the Quad Store)
- Theory
- Simple Example
- References
- SPARQL Query (i.e. we Sponge the Resources in the FROM Clause or values for the graph-uri paramater in SPARQL protocol URLs)
- Theory
- Simple Example
- References
- Virtuoso PL APIs
- Theory
- Simple Example
- References
- SIMILE RDF Bank API
- Theory
- Simple Example
- References
- RDF NET
- Theory
- Simple Example
- References
RDF Insert Methods in Virtuoso
RDF Sink Folders (Virtuoso or ODS-Briefcase)
HTTP Post using Content-Type: application/sparql-query
Theory
- With POST can be accomplished SPARQL Insert/Update etc.
- The result is in the rdf_quiad
- With GET Methods you can get the triples which are saved.
Simple Example 1
- Create a DAV collection and not to request for authentication set RW permissions for public. For ex. the collection path could be /DAV/xx
- Execute the following command:
curl -i -d "INSERT {<s> <p> <o>}" -H "Content-Type: application/sparql-query" http://host:port/DAV/xx/yy
- The response should be:
HTTP/1.1 201 Created Server: Virtuoso/05.00.3023 (Win32) i686-generic-win-32 VDB Connection: Keep-Alive Content-Type: text/html; charset=ISO-8859-1 Date: Fri, 28 Dec 2007 12:50:12 GMT Accept-Ranges: bytes MS-Author-Via: SPARQL Content-Length: 0
- As result in the DAV/xx location will be created a file with name "yy" and with the following content:
- if opened with Conductor:
CONSTRUCT { ?s ?p ?o } FROM <http://host:port/DAV/xx/yy> WHERE { ?s ?p ?o }
- if opened with GET, then the content will be RDF representation of what was inserted into the graph, i.e.
<?xml version="1.0" encoding="utf-8" ?> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> <rdf:Description rdf:about="s"><p rdf:resource="o"/></rdf:Description> </rdf:RDF>
- if opened with Conductor:
Simple Example 2
- Create a DAV collection, for ex. with name "test" for user ( for ex. demo).
- Execute the following command:
curl -i -d "INSERT IN GRAPH <http://example/testrq> { <s1> <p1> <o1> . <s2> <p2> <o2> . <s3> <p3> <o3> } " -u "demo:demo" -H "Content-Type: application/sparql-query" http://host:port/DAV/home/demo/test/myrq
- As result the response will be:
HTTP/1.1 201 Created Server: Virtuoso/05.00.3023 (Win32) i686-generic-win-32 VDB Connection: Keep-Alive Content-Type: text/html; charset=ISO-8859-1 Date: Thu, 20 Dec 2007 16:25:25 GMT Accept-Ranges: bytes MS-Author-Via: SPARQL Content-Length: 0
- Now let's check the inserted triples.
Go to the sparql endpoint, i.e.
http://host:port/sparql and:
- Enter for Default Graph URI:
http://example/testrq
- Enter in the Query area:
SELECT * WHERE {?s ?p ?o}
- Click the button "Run Query"
- As result will be shown the inserted triples:
s p o s1 p1 o1 s2 p2 o2 s3 p3 o3
- Enter for Default Graph URI:
HTTP PUT
Theory
"the URI in a PUT request identifies the entity enclosed with the request" (1). Therefore using HTTP PUT is a more useful and meaningful command than using POST (which is more about submitting data to a script).
Simple Usage Example
File: myfoaf.rdf Destination Server: demo.openlinksw.com curl -T myfoaf.rdf http://demo.openlinksw.com/DAV/home/demo/rdf_sink/myfoaf.rdf
References
SPARQL Insert using LOAD
SPARQL INSERT operation can be done using the LOAD feature.
Theory
Simple Example
- Execute from ISQL:
sparql insert in graph <http://example/load> { <l1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://rdfs.org/sioc/ns#User> . <l1> <http://rdfs.org/sioc/ns#name> <test1> . <l2> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://rdfs.org/sioc/ns#User> . <l2> <http://rdfs.org/sioc/ns#name> <test2> . <l3> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://rdfs.org/sioc/ns#User> . <l3> <http://rdfs.org/sioc/ns#name> <test3> . <l4> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://rdfs.org/sioc/ns#User> . <l4> <http://rdfs.org/sioc/ns#name> <demo> . };
- Create DAV collection which is visible to public, for ex: http://host:port/DAV/tmp
- Upload to the DAV collection the following file for ex.
with name listall.rq:
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://example/load> WHERE { ?x rdf:type sioc:User . ?x ?p ?o. ?x sioc:name ?name . FILTER REGEX(str(?name), "^test") } ORDER BY ?x
- Now from ISQL execute the following command:
sparql load bif:concat ("http://", bif:registry_get("URIQADefaultHost"), "/DAV/tmp/listall.rq") into graph <http://example/load2>;
- As result should be shown the message:
callret-0 VARCHAR _______________________________________________________________________________ Load <http://rumi.ath.cx:8895/DAV/tmp/listall.rq> into graph <http://example/load2> -- done 1 Rows. -- 321 msec.
SPARQL Insert via /sparql endpoint
SPARQL INSERT operation can be sent to a web service endpoint as a single statement and executed in sequence.
Theory
Simple Example
Using the Virtuoso ISQL tool or using the /sparql UI at http://host:port/sparql, execute the following:
- Insert into graph http://example/bookStore 3 triples:
sparql insert in graph <http://example/bookStore> { <s1> <http://purl.org/dc/elements/1.1/date> <1999-04-01T00:00:00> . <s2> <http://purl.org/dc/elements/1.1/date> <1998-05-03T00:00:00> . <s3> <http://purl.org/dc/elements/1.1/date> <2001-02-08T00:00:00> };
- As result will be shown the message:
Insert into <http://example/bookStore>, 3 triples -- done
- Next we will select all triples from the graph http://example/bookStore:
sparql select * from <http://example/bookStore> where {?s ?p ?o};
- As result will be shown:
s p o VARCHAR VARCHAR VARCHAR _______________________________________________________________________ s1 http://purl.org/dc/elements/1.1/date 1999-04-01T00:00:00 s3 http://purl.org/dc/elements/1.1/date 2001-02-08T00:00:00 s2 http://purl.org/dc/elements/1.1/date 1998-05-03T00:00:00 3 Rows. -- 0 msec.
- Now let's insert into graph another graph http://example/bookStore2 values:
sparql PREFIX dc: <http://purl.org/dc/elements/1.1/> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> INSERT INTO GRAPH <http://example/bookStore2> { ?book ?p ?v } WHERE { GRAPH <http://example/bookStore> { ?book dc:date ?date FILTER ( xsd:dateTime(?date) < xsd:dateTime("2000-01-01T00:00:00")). ?book ?p ?v. } };
- As result will be shown:
callret-0 VARCHAR _______________________________________________________________________________ Insert into <http://example/bookStore2>, 2 triples -- done
- Finally we will check the triples from the graph http://example/bookStore2:
SQL> sparql select * from <http://example/bookStore2> where {?s ?p ?o};
- As result will be shown:
s p o VARCHAR VARCHAR VARCHAR _______________________________________________________________________ s1 http://purl.org/dc/elements/1.1/date 1999-04-01T00:00:00 s2 http://purl.org/dc/elements/1.1/date 1998-05-03T00:00:00 2 Rows. -- 20 msec.
References
SPARQL Insert via HTTP Post using Content-Type: application/sparql-query and ODS wiki
Theory
- With HTTP Post and ODS wiki can be written an rdf document and respectively to be performed over it INSERT/UPDATE action.
- You can write to a file using SIOC terms for ODS-Wiki
- You can check with sparql the inserted / updated triples in the Quad Store.
Simple Example
- Suppose there is ODS user test3 with ODS password 1, which has testWiki wiki instance.
- Execute the following:
curl -i -d "INSERT {<http://host:port/dataspace/test3/wiki/testWiki> <http://atomowl.org/ontologies/atomrdf#contains> <http://host:port/dataspace/test3/wiki/testWiki/MyTest> . <http://host:port/dataspace/test3/wiki/testWiki/MyTest> <http://rdfs.org/sioc/ns#has_container> <http://host:port/dataspace/test3/wiki/testWiki> . <http://host:port/dataspace/test3/wiki/testWiki> <http://atomowl.org/ontologies/atomrdf#entry> <http://host:port/dataspace/test3/wiki/testWiki/MyTest> . <http://host:port/dataspace/test3/wiki/testWiki> <http://rdfs.org/sioc/ns#container_of> <http://host:port/dataspace/test3/wiki/testWiki/MyTest> . <http://host:port/dataspace/test3/wiki/testWiki/MyTest> <http://rdfs.org/sioc/ns#topic> <http://host:port/dataspace/test3/wiki/testWiki> . <http://host:port/dataspace/test3/wiki/testWiki/MyTest> <http://atomowl.org/ontologies/atomrdf#source> <http://host:port/dataspace/test3/wiki/testWiki> . <http://host:port/dataspace/test3/wiki/testWiki/MyTest> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://rdfs.org/sioc/types#Comment> . <http://host:port/dataspace/test3/wiki/testWiki/MyTest> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://atomowl.org/ontologies/atomrdf#Entry> . <http://host:port/dataspace/test3/wiki/testWiki/MyTest> <http://www.w3.org/2000/01/rdf-schema#label> 'MyTest' . <http://host:port/dataspace/test3/wiki/testWiki/MyTest> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://atomowl.org/ontologies/atomrdf#Link> . <http://host:port/dataspace/test3/wiki/testWiki/MyTest> <http://rdfs.org/sioc/ns#content> <test>}" -u "test3:1" -H "Content-Type: application/sparql-query" http://host:port/DAV/home/test3/wiki/testWiki/MyTest
- As result we should have 2 files created:
- In the user DAV folder "DAV/home/test3/wiki/testWiki/" will be created a file "MyTest?" with type "application/sparql-query".
- You can view the content of this file from from the Conductor UI or from the user's Briefcase UI, path "DAV/home/test3/wiki/testWiki":
- It content will be:
<?xml version="1.0" encoding="utf-8" ?> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> <rdf:Description rdf:about="http://host:port/dataspace/test3/wiki/testWiki"><ns0pred:entry xmlns:ns0pred="http://atomowl.org/ontologies/atomrdf#" rdf:resource="http://host:port/dataspace/test3/wiki/testWiki/MyTest"/></rdf:Description> <rdf:Description rdf:about="http://host:port/dataspace/test3/wiki/testWiki/MyTest"><ns0pred:label xmlns:ns0pred="http://www.w3.org/2000/01/rdf-schema#">MyTest</ns0pred:label></rdf:Description> <rdf:Description rdf:about="http://host:port/dataspace/test3/wiki/testWiki/MyTest"><ns0pred:type xmlns:ns0pred="http://www.w3.org/1999/02/22-rdf-syntax-ns#" rdf:resource="http://atomowl.org/ontologies/atomrdf#Link"/></rdf:Description> <rdf:Description rdf:about="http://host:port/dataspace/test3/wiki/testWiki/MyTest"><ns0pred:type xmlns:ns0pred="http://www.w3.org/1999/02/22-rdf-syntax-ns#" rdf:resource="http://rdfs.org/sioc/types#Comment"/></rdf:Description> <rdf:Description rdf:about="http://host:port/dataspace/test3/wiki/testWiki/MyTest"><ns0pred:type xmlns:ns0pred="http://www.w3.org/1999/02/22-rdf-syntax-ns#" rdf:resource="http://atomowl.org/ontologies/atomrdf#Entry"/></rdf:Description> <rdf:Description rdf:about="http://host:port/dataspace/test3/wiki/testWiki/MyTest"><ns0pred:has_container xmlns:ns0pred="http://rdfs.org/sioc/ns#" rdf:resource="http://host:port/dataspace/test3/wiki/testWiki"/></rdf:Description> <rdf:Description rdf:about="http://host:port/dataspace/test3/wiki/testWiki"><ns0pred:container_of xmlns:ns0pred="http://rdfs.org/sioc/ns#" rdf:resource="http://host:port/dataspace/test3/wiki/testWiki/MyTest"/></rdf:Description> <rdf:Description rdf:about="http://host:port/dataspace/test3/wiki/testWiki"><ns0pred:contains xmlns:ns0pred="http://atomowl.org/ontologies/atomrdf#" rdf:resource="http://host:port/dataspace/test3/wiki/testWiki/MyTest"/></rdf:Description> <rdf:Description rdf:about="http://host:port/dataspace/test3/wiki/testWiki/MyTest"><ns0pred:content xmlns:ns0pred="http://rdfs.org/sioc/ns#">test</ns0pred:content></rdf:Description> <rdf:Description rdf:about="http://host:port/dataspace/test3/wiki/testWiki/MyTest"><ns0pred:topic xmlns:ns0pred="http://rdfs.org/sioc/ns#" rdf:resource="http://host:port/dataspace/test3/wiki/testWiki"/></rdf:Description> <rdf:Description rdf:about="http://host:port/dataspace/test3/wiki/testWiki/MyTest"><ns0pred:source xmlns:ns0pred="http://atomowl.org/ontologies/atomrdf#" rdf:resource="http://host:port/dataspace/test3/wiki/testWiki"/></rdf:Description> </rdf:RDF>
- To the user's wiki instance will be added a new WikiWord? "MyTest?" with content the value of the SIOC term attribue "content":
<http://host:port/dataspace/test3/wiki/testWiki/MyTest> <http://rdfs.org/sioc/ns#content> <test> i.e. the content will be "test".
- You can view this filein path "DAV/home/test3/wiki/testWiki/" and its name will be "MyTest.txt".
- Using the ODS wiki UI you can:
- Go to Index link
- As result the MyTest? article will be shown in the given list. Click on its link.
- As result the content of the article will be shown.
- In the user DAV folder "DAV/home/test3/wiki/testWiki/" will be created a file "MyTest?" with type "application/sparql-query".
- Now lets check what data was inserted in the Quad Store:
- Go to the sparql endpoint, i.e. to http://host:port/sparql
- Enter for Default Graph URI:
http://host:port/DAV/home/test3/wiki/testWiki/MyTest
- Enter for Query text:
SELECT * WHERE {?s ?p ?o}
- Click the "Run Query" button.
- As result will be shown the inserted triples:
s p o http://host:port/dataspace/test3/wiki/testWiki http://rdfs.org/sioc/ns#container_of http://host:port/dataspace/test3/wiki/testWiki/MyTest http://host:port/dataspace/test3/wiki/testWiki http://atomowl.org/ontologies/atomrdf#entry http://host:port/dataspace/test3/wiki/testWiki/MyTest http://host:port/dataspace/test3/wiki/testWiki http://atomowl.org/ontologies/atomrdf#contains http://host:port/dataspace/test3/wiki/testWiki/MyTest http://host:port/dataspace/test3/wiki/testWiki/MyTest http://www.w3.org/1999/02/22-rdf-syntax-ns#type http://rdfs.org/sioc/types#Comment http://host:port/dataspace/test3/wiki/testWiki/MyTest http://www.w3.org/1999/02/22-rdf-syntax-ns#type http://atomowl.org/ontologies/atomrdf#Entry http://host:port/dataspace/test3/wiki/testWiki/MyTest http://www.w3.org/1999/02/22-rdf-syntax-ns#type http://atomowl.org/ontologies/atomrdf#Link http://host:port/dataspace/test3/wiki/testWiki/MyTest http://www.w3.org/2000/01/rdf-schema#label MyTest http://host:port/dataspace/test3/wiki/testWiki/MyTest http://rdfs.org/sioc/ns#has_container http://host:port/dataspace/test3/wiki/testWiki http://host:port/dataspace/test3/wiki/testWiki/MyTest http://rdfs.org/sioc/ns#content test http://host:port/dataspace/test3/wiki/testWiki/MyTest http://rdfs.org/sioc/ns#topic http://host:port/dataspace/test3/wiki/testWiki http://host:port/dataspace/test3/wiki/testWiki/MyTest http://atomowl.org/ontologies/atomrdf#source http://host:port/dataspace/test3/wiki/testWiki