You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Rob Styles <ro...@dynamicorange.com> on 2012/08/28 11:19:16 UTC

Command line vs fuseki Sparql

Hi all,

I have a Sparql query converting lat/long into a georss point:

PREFIX georss: <http://www.georss.org/georss/>
PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>
PREFIX fn: <http://www.w3.org/2005/xpath-functions#>
 
CONSTRUCT {
  ?thing georss:point ?point
} WHERE {
  ?thing geo:lat ?lat .
  ?thing geo:long ?long .
  LET ( ?point := fn:concat(?lat, ",", ?long) )
}
LIMIT 1

This works correctly when posting through the fuseki control panel. When I try to run this using the command line tools in Jena, either bin/sparql or tdbquery I get

Lexical error at line 10, column 6.  Encountered: " " (32), after : "LET"

Messing with parentheses and whitespace makes not material difference. Would it be that the Jena tools are working at 1.0 and fuseki at 1.1?

I need to run this on command line as without the limit 1 it will be a long-running query.

Is there a way to run this, or other suggestions for equivalent functionality? Some kind of inference rule?

rob

Re: Command line vs fuseki Sparql

Posted by Rob Styles <ro...@dynamicorange.com>.
Ah, of course. Thanks Andy. Have changed the query to use BIND as suggested and working now :)

rob

On 28 Aug 2012, at 10:38, Andy Seaborne <an...@apache.org> wrote:

> 
> LET is an ARQ-extension and Fuseki is parsing with extensions enabled.
> 
> In this case, BIND does the same thing.    BIND is SPARQL 1.1
> 
> So either tell the command line the query is ARQ-extended SPARQL 1.1 (one of file extension .arq, --format ARQ, use the comman arq.arq)
> 
> or use
> 
> BIND( fn:concat(?lat, ",", ?long) ) AS ?point)
> 
> You can also use a subquery:
> 
> CONSTRUCT {
>   ?thing georss:point ?point
> } WHERE {
>   { SELECT ?thing ( fn:concat(?lat, ",", ?long) ) AS ?point)
>     {
>       ?thing geo:lat ?lat .
>       ?thing geo:long ?long .
>     } LIMIT 1
>   }
> }
> 
>    Andy
> 
> On 28/08/12 10:19, Rob Styles wrote:
>> Hi all,
>> 
>> I have a Sparql query converting lat/long into a georss point:
>> 
>> PREFIX georss: <http://www.georss.org/georss/>
>> PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>
>> PREFIX fn: <http://www.w3.org/2005/xpath-functions#>
>> 
>> CONSTRUCT {
>>   ?thing georss:point ?point
>> } WHERE {
>>   ?thing geo:lat ?lat .
>>   ?thing geo:long ?long .
>>   LET ( ?point := fn:concat(?lat, ",", ?long) )
>> }
>> LIMIT 1
>> 
>> This works correctly when posting through the fuseki control panel. When I try to run this using the command line tools in Jena, either bin/sparql or tdbquery I get
>> 
>> Lexical error at line 10, column 6.  Encountered: " " (32), after : "LET"
>> 
>> Messing with parentheses and whitespace makes not material difference. Would it be that the Jena tools are working at 1.0 and fuseki at 1.1?
>> 
>> I need to run this on command line as without the limit 1 it will be a long-running query.
>> 
>> Is there a way to run this, or other suggestions for equivalent functionality? Some kind of inference rule?
>> 
>> rob
>> 
> 

Re: Command line vs fuseki Sparql

Posted by Andy Seaborne <an...@apache.org>.
LET is an ARQ-extension and Fuseki is parsing with extensions enabled.

In this case, BIND does the same thing.    BIND is SPARQL 1.1

So either tell the command line the query is ARQ-extended SPARQL 1.1 
(one of file extension .arq, --format ARQ, use the comman arq.arq)

or use

BIND( fn:concat(?lat, ",", ?long) ) AS ?point)

You can also use a subquery:

CONSTRUCT {
    ?thing georss:point ?point
} WHERE {
    { SELECT ?thing ( fn:concat(?lat, ",", ?long) ) AS ?point)
      {
        ?thing geo:lat ?lat .
        ?thing geo:long ?long .
      } LIMIT 1
    }
}

	Andy

On 28/08/12 10:19, Rob Styles wrote:
> Hi all,
>
> I have a Sparql query converting lat/long into a georss point:
>
> PREFIX georss: <http://www.georss.org/georss/>
> PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>
> PREFIX fn: <http://www.w3.org/2005/xpath-functions#>
>
> CONSTRUCT {
>    ?thing georss:point ?point
> } WHERE {
>    ?thing geo:lat ?lat .
>    ?thing geo:long ?long .
>    LET ( ?point := fn:concat(?lat, ",", ?long) )
> }
> LIMIT 1
>
> This works correctly when posting through the fuseki control panel. When I try to run this using the command line tools in Jena, either bin/sparql or tdbquery I get
>
> Lexical error at line 10, column 6.  Encountered: " " (32), after : "LET"
>
> Messing with parentheses and whitespace makes not material difference. Would it be that the Jena tools are working at 1.0 and fuseki at 1.1?
>
> I need to run this on command line as without the limit 1 it will be a long-running query.
>
> Is there a way to run this, or other suggestions for equivalent functionality? Some kind of inference rule?
>
> rob
>