TopBraid Live provides an out-of-the-box implementation of the W3C SPARQL 1.1 protocol. This can be used to execute SPARQL queries against the RDF models stored in the TopBraid workspace from web services.
The default URL of the SPARQL endpoint is
http://localhost:8080/tbl/tbl/sparql
in TopBraid Live and
http://localhost:8083/tbl/sparql
in TopBraid Composer ME. The SPARQL servlet supports both
query and
update operations.
Also note that the parameter named-graph-uri
is not supported yet
(but default-graph-uri
is). the following arguments are supported:
For example, if you would like to make a SELECT query against the kennedys ontology, use the following URL:
tbl/sparql?default-graph-uri=http://topbraid.org/examples/kennedys&query=SELECT ?p WHERE { ?p a ?t}
By default this will return the results in the SPARQL XML result set format. Other types
need to be specified either as values of format
or output
parameters in the URL or
in the HTTP request header's "Accept" property, with the following
permitted values:
Query type | Response type | Format name |
---|---|---|
ASK or SELECT | application/sparql-results+xml | SPARQL XML Results |
ASK or SELECT | application/sparql-results+json | SPARQL JSON Results |
ASK or SELECT | text/csv | Comma separated values |
ASK or SELECT | text/tab-separated-values | Tab separated values |
SELECT | application/sparql-results+json-simple | Simple JSON Format |
CONSTRUCT | application/rdf+xml | RDF/XML |
CONSTRUCT | text/turtle | Turtle |
TopBraid's SPARQL end point also supports abbreviated (short) graph names, as specified in the Configuration Parameters. For example the following syntax is valid and would use the kennedys graph as the default graph:
/tbl/sparql/kennedys?query=...
If you have specified a default graph URI then you can also instruct the SPARQL end point to use all owl:imports of that graph (and its imports, recursively) by passing the parameter
with-imports=true
Note that in TopBraid Live deployments, the TBL user permissions framework defines which named graphs can be accessed by the currently logged in user.
SPARQL Endpoint Update
SPARQL Update statements can be executed from the SPARQL Endpoint. By default, SPARQL Endpoint Updates are disabled. To enable updates set the 'Advanced Parameter' named "Enable SPARQL updates" to true in the Server Configuration Parameters page (see the server Administration page).
SPARQL Update statements are supported using the sparql servlet, using the 'update' parameter. The update servlet takes a single parameter that defines the SPARQL Update query. Note that the query must therefore explicitly specify a graph context to execute the update in using the GRAPH <...> syntax. An example update call is shown in the following URL:
tbl/sparql?update=INSERT{ GRAPH <http://topbraid.org/examples/kennedys>{ <http://topbraid.org/examples/kennedys%23JohnKennedy> <http://www.w3.org/2000/01/rdf-schema%23comment> "a new comment"}} WHERE {}
Access controls can also be defined for SPARQL Update using the Permission Group Management page and the SPARQLUpdateAllowGrp and SPARQLUpdateDenyGrp. For more information see the Permission Group Management admin page.
TopBraid supports an optional parameter check=resources
to instruct the SPARQL update
processor to perform constraint checking before asserting the changes.
The constraints will be checked for all subjects that are modified by the UPDATE, in the context
of the named graphs that are mentioned in the INSERT or DELETE statements.
If at least one constraint violation error is found, the operation will stop with an error.
TopBraid also supports an optional argument logMessage
which may contain a string
that shall be used for any change history entries created by the operation.
This is only supported when the graph being updated is under EDG teamwork control, i.e.
the updated graph must be something like urn:x-evn-master:geo:Administrator
.
SPARQL Endpoint Connection Files
In TopBraid Composer, you can also create a connection file to SPARQL Endpoint.