Я новичок в Jena и SPARQL. Я пытаюсь запустить Jena в Eclipse со следующим запросом и кодом. Я получаю QueryParseException, я знаю, что у других была такая же проблема с неопределенным префиксом rdfs, но здесь все по-другому.
Исключение:
Exception in thread "main" org.apache.jena.query.QueryParseException: Line 1, column 134: Unresolved prefixed name: http:
Запрос:
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?subject ?fsn
WHERE {
?subject rdfs:label ?fsn.
?subject rdfs:subClassOf+ http://snomed.info/id/410607006
}
Код:
import java.util.HashMap;
import org.apache.jena.query.*;
public class SnomedQuery {
private String serviceURI;
private String query;
//Constructor with SPARQL endpoint and query
public SnomedQuery(String URI, String serviceURI){
this.serviceURI = serviceURI;
this.query = "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>" +
" SELECT ?subject ?fsn WHERE {?subject rdfs:label ?fsn. ?subject rdfs:subClassOf+ "+URI+"}";
}
//return SPARQL endpoint
public String getServiceURI() {
return this.serviceURI;
}
//return query
public String getQuery() {
return this.query;
}
/*
* purpose: This function is used to retrieve all child of a concept and the concept itself
* @param
* @return
* Hashmap with URI as key and corresponding term as value
*/
public HashMap<String, String> getFSNChildPlus(){
HashMap<String, String> output = new HashMap<String, String>();
QueryExecution q = QueryExecutionFactory.sparqlService(getServiceURI(), getQuery());
ResultSet results = q.execSelect();
while (results.hasNext()) {
QuerySolution answer = results.nextSolution();
String subject = answer.get("subject").toString();
String fsn = answer.get("fsn").toString();
output.put(subject, fsn);
}
return null;
}
}
Спасибо за помощь




В SPARQL необходимо разметить URI.
Итак, http://snomed.info/id/410607006 неправильный, но <http://snomed.info/id/410607006> в порядке.
Вот ваш запрос:
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?subject ?fsn
WHERE {
?subject rdfs:label ?fsn.
?subject rdfs:subClassOf+ <http://snomed.info/id/410607006>
}