• Places
    • Home
    • Graphs
    • Prefixes
  • Admin
    • Users
    • Settings
    • Plugins
    • Statistics
  • CPACK
    • Home
    • List packs
    • Submit pack
  • Repository
    • Load local file
    • Load from HTTP
    • Load from library
    • Remove triples
    • Clear repository
  • Query
    • YASGUI SPARQL Editor
    • Simple Form
    • SWISH Prolog shell
  • Help
    • Documentation
    • Tutorial
    • Roadmap
    • HTTP Services
  • Login

/usr/lib/swipl/library/ext/semweb/semweb/sparql_client.pl
All Application Manual Name SummaryHelp

  • semweb
    • semweb
      • rdf_db.pl -- Core RDF database
      • rdf_prefixes.pl -- RDF prefixes management
      • rdfs.pl -- RDFS handling
      • rdf11.pl -- RDF 1.1 API
      • rdf_persistency.pl -- RDF persistency plugin
      • rdf_litindex.pl -- Search literals
      • rdf_ntriples.pl -- Process files in the RDF N-Triples format
      • sparql_client.pl -- SPARQL client library
        • sparql_query/3
        • sparql_set_server/1
        • sparql_read_xml_result/2
        • sparql_read_json_result/2
      • rdf_http_plugin.pl -- RDF HTTP Plugin
      • rdf_turtle_write.pl -- Turtle - Terse RDF Triple Language writer
      • turtle.pl -- Turtle: Terse RDF Triple Language
      • rdf_library.pl -- RDF Library Manager
      • rdf_turtle.pl -- Turtle reader
      • rdf_cache.pl -- Cache RDF triples
      • rdf_sandbox.pl -- Declare RDF API sandbox-safe
      • rdf_zlib_plugin.pl -- RDF compressed-data plugin
 sparql_query(+Query, -Result, +Options) is nondet
Execute a SPARQL query on an HTTP SPARQL endpoint. Query is an atom that denotes the query. Result is unified to a term rdf(S,P,O) for CONSTRUCT and DESCRIBE queries, row(...) for SELECT queries and true or false for ASK queries. Options are

Variables that are unbound in SPARQL (e.g., due to SPARQL optional clauses), are bound in Prolog to the atom '$null$'.

endpoint(+URL)
May be used as alternative to Scheme, Host, Port and Path to specify the endpoint in a single option.
host(+Host)
port(+Port)
path(+Path)
scheme(+Scheme)
The above four options set the location of the server.
search(+ListOfParams)
Provide additional query parameters, such as the graph.
variable_names(-ListOfNames)
Unifies ListOfNames with a list of atoms that describe the names of the variables in a SELECT query.

Remaining options are passed to http_open/3. The defaults for Host, Port and Path can be set using sparql_set_server/1. The initial default for port is 80 and path is `/sparql/`.

For example, the ClioPatria server understands the parameter entailment. The code below queries for all triples using _rdfs_entailment.

?- sparql_query('select * where { ?s ?p ?o }',
                Row,
                [ search([entailment=rdfs])
                ]).

Another useful option is the request_header which, for example, may be used to trick force a server to reply using a particular document format:

?- sparql_query(
       'select * where { ?s ?p ?o }',
        Row,
        [ host('integbio.jp'),
          path('/rdf/sparql'),
          request_header('Accept' =
                         'application/sparql-results+xml')
        ]).
ClioPatria (version V3.1.1-51-ga0b30a5)