On Wed, Aug 21, 2013 at 6:24 AM, Darius Miliauskas
<[email protected]> wrote:
> Thanks, guys, I do not know what is wrong but when I try to use "VALUES" I
> got org.openrdf.query.MalformedQueryException. Encountered: " " after:
> "values". I have read the specification of SPARQL, tried several different
> ways but the same error is still on. Even my simplified query looks like
> this:
>
> SELECT ?person ?city WHERE {
> VALUES (?person ?city) {
> (base:person
> base:city)
>   }
> ?person a base:Person.
> ?city a base:city.
> }
>
> Error is on the line "VALUES (?person ?city) {".
>
>
> Yours,
>
> Darius


VALUES was introduced in SPARQL 1.1, so if you're querying against an
endpoint that uses the older version of SPARQL, VALUES will be
rejected. Similarly, if you're trying to *parse* the query as SPARQL
1.1, you'll get this sort of issue.

I only used VALUES in the first query that I sent you as a way of
restricting the results to one row so that they'd be easier to copy
and paste into an email without making it huge.  Your simplified query
doesn't end up leaving any variable *unbound*, and could just be:

SELECT ?person ?city WHERE {
  base:person a base:Person.
  base:cite a base:city.
}

VALUES is useful when you need to say "this sequence of variables, can
have each binding in this set."  If there's only one binding in that
set, you don't need values, and you can just write the values inline,
as I did above.

//JT

-- 
Joshua Taylor, http://www.cs.rpi.edu/~tayloj/

Reply via email to