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:

  1. 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 . } }

  2. 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 . }

    1. View the SPARQL Query Definition via SPARQL Protocol URL;
    2. View the SPARQL Query Results via SPARQL Protocol URL;
  3. 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) } }

    1. View the SPARQL Query Definition via SPARQL Protocol URL;
    2. View the SPARQL Query Results via SPARQL Protocol URL.

Related