Corese Server version 3.1.5

URL for SPARQL endpoint


SPARQL template return HTML

http://localhost:8080/srv/template?query=select * where { ?x ?p ?y }

Specify character encoding

java -Dfile.encoding=UTF-8 -jar corese-server.jar

Load RDF/RDFS/OWL/Rules source

java -jar corese-server.jar -l /home/user/data/...

Load several sources: separate them with ";"

java -jar corese-server.jar -l "/home/user/data1;/home/user/data2"

Other server options

-e        -- RDFS entailments
-o        -- OWL RL entailments 

RDF Introspection

Information about the system available as (extended) named graphs.

graph eng:describe { bind (st:atw(st:turtle) as ?g1) }
graph eng:queries  { bind (st:atw(st:spin)   as ?g2) }

graph eng:engine   { bind (st:atw(st:spin)   as ?g3) }
graph eng:record   { bind (st:atw(st:turtle) as ?g4) }


Triples entailed by rule store their provenance, it is accessible using SPARQL.

The SPIN graph of the rule is accessible using an extended named graph.

select * 
from kg:rule
where {
  ?x ?p ?y
  bind (kg:provenance(?p) as ?pr)
  graph ?pr { [] sp:predicate ?q }

SPARQL Template Transformation

st:turtle st:spin st:owl

Pretty print a resource in a SPARQL Query:

prefix sp: <> 
select (st:apply-templates-with(st:spin, ?x) as ?px)
where {
  ?x a sp:Select

Pretty print a resource in a template query:

template {
  st:apply-templates-with(st:owl, ?x) 
  ; separator = "\n"
where {
  ?x a owl:Class

STTL Function list


Pretty Printing Template

template {
  "ObjectAllValuesFrom(" st:uri(?y) " " st:uri(?z) ")"  
where {
  ?in a owl:Restriction ;
    owl:onProperty ?y ;
    owl:allValuesFrom ?z .

Pretty print a graph by program.

TemplateFormat tf = TemplateFormat.create(g, pp);

TemplateFormat tf = TemplateFormat.create(map, pp);




Distributed Query

Graph g =  Graph.create();
QueryProcessDQP exec = QueryProcessDQP.create(g);

exec.addRemote(new URL(""), WSImplem.REST);
exec.addRemote(new URL(""), WSImplem.REST);

Mappings map = exec.query(q);

SPIN Syntax

SPINProcess sp = SPINProcess.create();
String sparql  = "select * where { ?x ?p ?y };
String spin = sp.toSpin(sparql);
String str  = sp.toSparql(spin);

Corese Server

java -jar corese-server.jar

Via Web Browser:


RDF List

Rewrite RDF List as rdf:rest*/rdf:first

select * where {
?q a sp:Select ;
  sp:elements @(
     [ sp:object 1 ]
     [ sp:object 2 ]

Rewritten as:

select * where {
?q a sp:Select ;
  sp:elements [
     rdf:rest*/rdf:first [ sp:object 1 ] ;
     rdf:rest*/rdf:first [ sp:object 2 ]




Assign a class style to a node in GUI.

construct {
  ?x kg:style "label"
where {

node.label {



API for pragma:

exec.addPragma(Pragma.PATH, Pragma.EXPAND, 100);

Timeout for service

pragma { kg:service kg:timeout 100 }


Property Path Expansion

Rewrite Property Path as a Basic Graph Pattern. Useful with service clause in the case where the target server is SPARQL 1.0. Usage: with a pragma or with the API. Number "n" is the length of the chain generated to rewrite a loop (+ or *).

pragma {kg:path kg:expand n}



Graph as Query

Use an RDF graph as a query graph pattern.

Graph g = Graph.create();
Mappings map = exec.query(g);

Mappings map = exec.query("construct {...} where {...}");

Graph qg = exec.getGraph(map);



Graph Listener

To trace edge creation and deletion.

graph.addListener( new GraphListener() { ... });

interface GraphListener {
  void addSource(Graph g);
  void insert(Entity ent);
  void delete(Entity ent);



Slice dynamic bindings sent to service.

pragma {kg:service kg:slice 50}


SPARQL 1.1 Property Path

Not counting semantics implemented.

SPARQL 1.1 Values pattern

values ?x { <uri> }

values (?x ?y) { ( <uri> 12 ) }

SPARQL 1.1 Service pattern

service <> { 
?x ?p ?y 

Path Expansion


?x foaf:knows+ ?y

may be compiled as

{?x foaf:knows ?y} union {?x foaf:knows [foaf:knows ?y]}

with a Visitor. Use case: sparq 1.0 service


select * where {
?x foaf:knows+ ?y
pragma {kg:path kg:expand 10}


SPARQL XML Result Parser

Producer p = ProducerImpl.create(Graph.create());
XMLResult r = XMLResult.create(p);
Mappings map = r.parseString(xmlres);


Visitor plugin for ASTQuery after SPARQL parsing and for Query after compiling.

public interface QueryVisitor {
  void visit(ASTQuery ast);
  void visit(Query query);
exec.set(new VisitorImpl());

Filter on Mappings

Mappings map = exec.query(query);
exec.filter(map, "?x >= 12");

QueryProcess with several graphs

Local subsumption for each graph is possible. Hence each graph can have its own (version of) ontology.

QueryProcess exec = QueryProcess.create(g1, true);


Command Line

java -cp corese.jar fr.inria.edelweiss.kgtool.Start 
  -load data.rdf 
  -query "select * where {?x ?p ?y}"