Semweb4j/filesQueries/step6
From semanticweb.org
Up | Previous step | Next step
[edit] Step 6: SPARQL DESCRIBE
As in step 5, we don't explain the basic setup again.
[edit] DESCRIBE queries
DESCRIBE queries are always executed via model.sparqlDescribe which returns a ClosableIterable of Statements (like CONSTRUCT).
DESCRIBE just returns a graph (a subgraph of your model) with every statement where the resources you've selected appear.
Describe the resource max:
System.out.println("Query 1:");
String queryString = "DESCRIBE <"+max+">";
ClosableIterable<? extends Statement> results = model.sparqlDescribe(queryString);
for(Statement result : results ) {
System.out.println(result);
}
Describe every resource tagged with "Java":
System.out.println("Query 2:");
queryString = "DESCRIBE ?resource WHERE { ?resource <"+hasTag+"> "+tagJava.toSPARQL()+" }";
results = model.sparqlDescribe(queryString);
for(Statement result : results ) {
System.out.println(result);
}
The graph returned by this query does not contain only tagging statements but all statements about resources which are tagged with "Java".
As you see (at least after looking at the program's output), DESCRIBE queries are simple.
[edit] output
Query 1: http://xam.de/foaf.rdf.xml#i--http://xmlns.com/foaf/0.1/#term_name--Max Völkel http://xam.de/foaf.rdf.xml#i--http://example.com/relations#age--29^^http://www.w3.org/2001/XMLSchema#integer http://xam.de/foaf.rdf.xml#i--http://example.com/relations#hasTag--Java Query 2: http://example.com/persons#james--http://xmlns.com/foaf/0.1/#term_name--James Gosling http://example.com/persons#james--http://example.com/relations#hasTag--Java http://xam.de/foaf.rdf.xml#i--http://xmlns.com/foaf/0.1/#term_name--Max Völkel http://xam.de/foaf.rdf.xml#i--http://example.com/relations#age--29^^http://www.w3.org/2001/XMLSchema#integer http://xam.de/foaf.rdf.xml#i--http://example.com/relations#hasTag--Java http://example.com/persons#konrad--http://xmlns.com/foaf/0.1/#term_name--Konrad Völkel http://example.com/persons#konrad--http://example.com/relations#age--19^^http://www.w3.org/2001/XMLSchema#integer http://example.com/persons#konrad--http://example.com/relations#hasTag--Java http://example.com/persons#konrad--http://example.com/relations#hasTag--Python
