Yep, now that I know that's not legal syntax, I'll rewrite my query using the second syntax you quoted.

Chris


On 7/14/2016 11:58 AM, Andy Seaborne wrote:
?s ?p1/?p2 ?o

is also

?s ?p1 [ ?p2 ?o ] .

ARQ expands / anyway.

Or

?s ?p1 ?X .
?X ?p2 ?o .

(internally the ?X is a variable that can't clash with one in the query)

    Andy


On 14/07/16 17:58, 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 <aj...@virginia.edu> 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 <ch...@cjones.org> 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