I want to do a nested query towards dbpedia with a select expression in the 
results part.
This works well when I use the dbpedia online query service, but will not work 
with jena.
But jena's parser called in QueryFactory.create() does not seem to like SELECT 
in the results part.

A simplified version of the query I build and try to send is:

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX : <http://dbpedia.org/resource/>
PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>
PREFIX dbpediaont: <http://dbpedia.org/ontology/> 
SELECT  distinct ?y 
        ((SELECT count(*) WHERE {?y ?r1 ?z}) as ?c1)
        ?c3 ?label WHERE 
        {{SELECT ?y 
                         (count(?r3) as ?c3) 
                         ?label WHERE {
                 <http://dbpedia.org/resource/Simpson,_Milton_Keynes> ?r3 ?y . 
                 ?y rdfs:label ?label.
                 FILTER (lang(?label) = "en")}}} 

Adds Java code (this has nothing to do with it I believe, as I have tried all 
variants of syntaxes in the parameter list of the QueryFactory.create()):
                ...
                String dbpediaEndpointUri = "http://dbpedia.org/sparql";;
                // Builds query.
                Query query = 
QueryFactory.create(buildQuery(lt.getSubject()),Syntax.syntaxSPARQL);
                QueryExecution qe = QueryExecutionFactory.sparqlService(
                                dbpediaEndpointUri, query, 
"http://dbpedia.org";);
                ResultSet resSet = qe.execSelect();

According to what I have read, this should be allowed in SPARQL 1.1  and in 
ARQ, so what is the problem.
Doesn't jena support the full language?

The error message I get  is (which is exactly the same as for the larger query 
asking for some more data):

Exception in thread "main" com.hp.hpl.jena.query.QueryParseException: 
Encountered " "select" "SELECT "" at line 7, column 11.
Was expecting one of:
    <IRIref> ...
    <PNAME_NS> ...
    <PNAME_LN> ...
    <VAR1> ...
    <VAR2> ...
    "exists" ...
    "not" ...
   etc....

Bjørnar Tessem

Reply via email to