Add prefixes to queries in SPARQL

731 Views Asked by At

I am running the following query using the apache jena sparql library in java:

String queryString ="SELECT ?startTime ?endTime " +
                    "WHERE { " +
                            "?y  rdfs:label  \"Processor execution GETIMAGE\" . "+
                            "?y  prov:startedAtTime  ?startTime . "+
                            "?y  prov:endedAtTime  ?endTime . " +
                    "}";

Query query = QueryFactory.create(queryString);
QueryExecution qe = QueryExecutionFactory.create(query, model);

However, this results in a Unresolved prefixed name exception. I know that it is possible to fix this by adding the full name of the prefixes in my query string (as was shown in Unresolved prefixed name: rdfs:subClassOf in SPARQL query), but I was wondering if there is a way to import these prefix declarations from the rdf model into the query.

0

There are 0 best solutions below