Virtuoso SPARQL 1.1. VALUES Usage Examples
What?
This guide contains Virtuoso SPARQL 1.1. VALUES Usage example queries which you can run against any SPARQL endpoint that supports SPARQL 1.1 and the ability to allow a verified user perform INSERT operations.Why?
SPARQL 1.1 provides a mechanism for inline incorporation of Data as part SPARQL query patterns.How?
Here are some examples showcasing Virtuoso's support for this functionality:
- Assume the following statement for inserting triples INTO DBMS or Store:
PREFIX : <http://example.org/book/> PREFIX ns: <http://example.org/ns#> INSERT { GRAPH <urn:sparql:bind:tests> { :book1 <http://purl.org/dc/elements/1.1/title> "SPARQL Tutorial" . :book1 ns:price 42 . :book1 ns:discount 0.2 . :book2 <http://purl.org/dc/elements/1.1/title> "The Semantic Web" . :book2 ns:price 23 . :book2 ns:discount 0.25 . } }
- From a Virtuoso SPARQL Endpoint ( http://host:port/sparql ) query the graph by executing the query from below for ex.:
PREFIX : <http://example.org/book/> PREFIX ns: <http://example.org/ns#> SELECT ?book ?title ?price FROM <urn:sparql:bind:tests> WHERE { VALUES ?book { :book1 :book3 } ?book <http://purl.org/dc/elements/1.1/title> ?title ; ns:price ?price . }
- Alternative variant of the query:
PREFIX : <http://example.org/book/> PREFIX ns: <http://example.org/ns#> SELECT ?book ?title ?price FROM <urn:sparql:bind:tests> WHERE { ?book <http://purl.org/dc/elements/1.1/title> ?title ; ns:price ?price . VALUES (?book ?title) { (UNDEF "SPARQL Tutorial") (:book2 UNDEF) } }
Related
- SPARQL 1.1. inline data via use of VALUES clause
- Virtuoso Tips and Tricks Collection
- Virtuoso SPARQL 1.1 Usage Examples Collection
- Virtuoso SPARQL 1.1 Syntax Tutorial
- Virtuoso SPARQL 1.1 VALUES Tutorial
- Virtuoso SPASQL And SPARQL Tutorial
- Virtuoso Documentation