On 06/12/12 16:43, Elli Schwarz wrote:
Hello,
I'm getting an exception thrown for running a query through
QueryExecutionFactory.sparqlService - yet running the exact same query directly
in Fuseki works properly.
I have the following Java code snippet:
String queryString = "prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n"
+ "prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n"
+ "select * where {\n"
+ " {select * where {\n"
+ " ?s1 ?p1 [\n"
+ " rdfs:label ?label\n"
+ " ]. }}\n"
+ " {select * where {\n"
+ " ?s2 ?p2 [\n"
+ " rdf:type ?type\n"
+ " ].
}}\n"
+ "} limit 50";
QueryExecution queryExec = QueryExecutionFactory.sparqlService(
"http://localhost:3030/ds/query", queryString);
ResultSet rs = queryExec.execSelect();
When I try to run this query, I get this exception :
HttpException: 400 Parse error: PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> PREFIX rdf:
<http://www.w3.org/1999/02/22-rdf-syntax-ns#> SELECT * WHERE { { SELECT * WHERE
{ ?s1 ?p1 _:b0 . _:b0 rdfs:label ?label } } { SELECT *
WHERE { ?s2 ?p2 _:b0 . _:b0 rdf:type ?type } } } LIMIT 50
Line 15, column 19: Blank node label reuse not allowed at this point: _:b0
Error 400: Parse error:
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT *
WHERE
{ { SELECT *
WHERE
{ ?s1 ?p1 _:b0 .
_:b0 rdfs:label ?label
}
}
{ SELECT *
WHERE
{ ?s2 ?p2 _:b0 .
_:b0 rdf:type ?type
}
}
}
LIMIT 50
Line 15, column 19: Blank node label reuse not allowed at this point: _:b0
It appears that sparqlService resolves the [ ] notation in advance, before it
sends the query to Fuseki, and Fuseki is getting invalid SPARQL. The problem
seems to occur only if there are two subqueries that are using the [ ] notation
for blank nodes, and it tries to use the same blank node ID in both subqueries
- if I run this query w/o using subqueries it works fine. Again, running the
query directly in Fuseki works. I'm using Jena 2.7.4, ARQ 2.9.4, and Fuseki
0.2.5 APIs.
Thank you for your assistance!
-Elli
> It appears that sparqlService resolves the [ ] notation in advance
Yes it does. The query is parsed locally (to check for errors)
You can use QueryEngineHTTP directly if you need to pass in the exact
string.
SPARQL does not allow a bNode label to be used in two different Basic
graph Patterns (it confuses entailment).
It is a printing problem in ARQ - it restarts the bNode labeling in
inner queries.
I've recorded this as:
https://issues.apache.org/jira/browse/JENA-361
Andy