0

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.

Elias
  • 432
  • 6
  • 17
  • No, because prefixes are **not** part of an RDF dataset. It's just part of some serializations. For example, in `N-Triples` there are no prefix declarations. – UninformedUser Jan 10 '19 at 14:22
  • For languages like `RDF/XML` and `Turtle`, you might be lucky and get the parsed prefixes from the `model.getNsPrefixMap()`. You still have to build the prefix declaration for the SPARQL query, if you just want a subset of all prefix declarations. Otherwise, use `query.setPrefixMapping` method – UninformedUser Jan 10 '19 at 18:33
  • @AKSW Please let me know your thoughts about this question: https://stackoverflow.com/questions/56021067/how-to-add-a-list-as-a-parameter-in-sparql-query-in-python I look forward to hearing from you. Thank you very much :) – EmJ May 07 '19 at 11:00

0 Answers0