On 14/07/16 19:04, Chris Jones wrote:
In that case, can I request a better error message? What it told me was
confusing.

Pull request welcome!


The grammar is exactly the SPARQ 1.1 spec grammar - the javacc was used to create both the HTML for the spec and the Jena java parser.

It takes a special rule to trigger specific error messages - the grammar must be modified; not a lot but then it diverges.

Adding it to the ARQ extended parser does not have that issue.

        Andy


Chris


On 7/14/2016 10:58 AM, Joshua TAYLOR wrote:
You can't use variables in property paths, so

?p1/?p2

isn't a legal property path.  You shouldn't be able to parse it as a
legal query.  As an alternative (which I'm not sure will work, but it
might be worth investigating), you could use a
ParameterizedSparqlString with "?s ?p1/?p2 ?o" as content and do
substitutions on ?p1 and ?p2 in that, which would generate a legal
query.  I'm not sure whether the substitution would be performed
before any parsing has to happen though (that's why I'm not *sure*
that this would work).

On Thu, Jul 14, 2016 at 12:47 PM, A. Soroka <[email protected]> wrote:
I don't quite see how this would cause the problem, but I do note
that of the three bindings in your code below, the first is _not_ to
"s" (as you say in your description), but to "o".

---
A. Soroka
The University of Virginia Library

On Jul 14, 2016, at 12:09 PM, Chris Jones <[email protected]> wrote:

I'm building a simple query of the form "?s ?p1 / ?p2 ?o" and
binding s, p1, and p2 using QuerySolutionMap. I get this error back:

Exception in thread "main"
org.apache.jena.query.QueryParseException: Encountered " "/" "/ ""
at line 1, column 26.

Here's the code that reproduces the error, using Jena 3.1.0:

package org.cjones.test;

import org.apache.jena.query.*;
import org.apache.jena.rdf.model.ResourceFactory;
import org.apache.jena.tdb.TDBFactory;

public class Test {
    public static void main(String[] args) {
        Dataset dataset = TDBFactory.createDataset("db");
        String queryStr ="select ?o where { ?s ?p1 / ?p2 ?o }";
        QuerySolutionMap bindings =new QuerySolutionMap();
        bindings.add("o",
ResourceFactory.createResource("http://example.com/Alice";));
        bindings.add("p1",
ResourceFactory.createResource("http://example.com/boss";));
        bindings.add("p2",
ResourceFactory.createResource("http://example.com/givenName";));
        dataset.begin(ReadWrite.READ);
        QueryExecution qe = QueryExecutionFactory.create(queryStr,
dataset, bindings);
        ResultSet rs = qe.execSelect();
        // ... dataset.end();
    }
}

I don't think I'm doing anything wrong, am I?

Chris





Reply via email to