You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Jean-Marc Vanel <je...@gmail.com> on 2017/02/16 14:52:10 UTC
Likely bug: short form for the CONSTRUCT query + GRAPH => syntax error
Hi
I tested with 3.2.0.
The short form for the CONSTRUCT query
https://www.w3.org/TR/sparql11-query/#constructWhere
works, at least syntactically ( I have nothing in the default graph in my
TDB ) :
CONSTRUCT WHERE
{ ?X ?P ?O . }
LIMIT 10
But adding GRAPH pattern gives a synyax error:
CONSTRUCT WHERE {
GRAPH ?G {
?X ?P ?O .
}
} LIMIT 10
Which does not occur e.g. with Virtuoso.
org.apache.jena.query.QueryParseException: Encountered " "graph" "GRAPH ""
at line 2, column 1.
Was expecting one of:
<IRIref> ...
<PNAME_NS> ...
<PNAME_LN> ...
<BLANK_NODE_LABEL> ...
<VAR1> ...
<VAR2> ...
"true" ...
"false" ...
<INTEGER> ...
<DECIMAL> ...
<DOUBLE> ...
<INTEGER_POSITIVE> ...
<DECIMAL_POSITIVE> ...
<DOUBLE_POSITIVE> ...
<INTEGER_NEGATIVE> ...
<DECIMAL_NEGATIVE> ...
<DOUBLE_NEGATIVE> ...
<STRING_LITERAL1> ...
<STRING_LITERAL2> ...
<STRING_LITERAL_LONG1> ...
<STRING_LITERAL_LONG2> ...
"(" ...
<NIL> ...
"}" ...
"[" ...
<ANON> ...
at
org.apache.jena.sparql.lang.ParserSPARQL11.perform(ParserSPARQL11.java:100)
--
Jean-Marc Vanel
http://www.semantic-forms.cc:9111/display?displayuri=http://jmvanel.free.fr/jmv.rdf%23me
Déductions SARL - Consulting, services, training,
Rule-based programming, Semantic Web
+33 (0)6 89 16 29 52
Twitter: @jmvanel , @jmvanel_fr ; chat: irc://irc.freenode.net#eulergui
Re: Likely bug: short form for the CONSTRUCT query + GRAPH => syntax
error
Posted by Andy Seaborne <an...@apache.org>.
On 16/02/17 20:37, Martynas Jusevi\u010dius wrote:
> It has to be a basic pattern:
> https://www.w3.org/TR/sparql11-query/#constructWhere
Yes.
CONSTRUCT WHERE { P } is a short form for
CONSTRUCT { P } WHERE { P }
(In fact, that is how it is executed.)
The restrictions on P used as a template apply.
"CONSTRUCT WHERE" is extract this subgraph where the subgraph
description is restricted to what is allowed in a tenplate.
Turtle+Variables.
[52] TriplesTemplate ::=
TriplesSameSubject ( '.' TriplesTemplate? )?
Andy
>
> On Thu, 16 Feb 2017 at 21.31, Jean-Marc Vanel <je...@gmail.com>
> wrote:
>
>> Indeed adding syntaxARQ brings a progress:
>> QueryFactory.create(query, Syntax.syntaxARQ)
>>
>> GRAPH is tolerated,
>> but OPTIONAL is not:
>>
>> Exception in thread "main" org.apache.jena.query.QueryParseException:
>> Encountered " "optional" "OPTIONAL "" at line 9, column 11.
>> Was expecting one of:
>> <IRIref> ...
>> <PNAME_NS> ...
>> <PNAME_LN> ...
>> <BLANK_NODE_LABEL> ...
>> <VAR1> ...
>> <VAR2> ...
>> "true" ...
>> "false" ...
>> <INTEGER> ...
>> <DECIMAL> ...
>> <DOUBLE> ...
>> <INTEGER_POSITIVE> ...
>> <DECIMAL_POSITIVE> ...
>> <DOUBLE_POSITIVE> ...
>> <INTEGER_NEGATIVE> ...
>> <DECIMAL_NEGATIVE> ...
>> <DOUBLE_NEGATIVE> ...
>> <STRING_LITERAL1> ...
>> <STRING_LITERAL2> ...
>> <STRING_LITERAL_LONG1> ...
>> <STRING_LITERAL_LONG2> ...
>> "(" ...
>> <NIL> ...
>> "}" ...
>> "[" ...
>> <ANON> ...
>>
>> at
>> org.apache.jena.sparql.lang.ParserSPARQL11.perform(ParserSPARQL11.java:100)
>> at
>> org.apache.jena.sparql.lang.ParserSPARQL11.parse$(ParserSPARQL11.java:52)
>>
>>
>>
>> 2017-02-16 17:54 GMT+01:00 Rob Vesse <rv...@dotnetrdf.org>:
>>
>>> As a general comment the short form of construct is very constrained.
>>> Anything other than that simple triple patterns is illegal in the short
>> form
>>>
>>> Rob
>>>
>>> On 16/02/2017 16:45, "Andy Seaborne" <an...@apache.org> wrote:
>>>
>>> Hi,
>>>
>>> The result of a CONSTRUCT is an RDF graph and the template must be a
>>> "triples template"
>>>
>>> [10] ConstructQuery ::=
>>> 'CONSTRUCT' ... 'WHERE' '{' TriplesTemplate? '}' ...
>>>
>>> and
>>>
>>> [52] TriplesTemplate ::=
>>> TriplesSameSubject ( '.' TriplesTemplate? )?
>>>
>>> No GRAPH.
>>>
>>> Jena accepts CONSTRUCT WHERE { GRAPH .... }
>>> in extended mode (Syntax.syntaxARQ) and returns a Dataset.
>>>
>>> Andy
>>>
>>>
>>> On 16/02/17 14:52, Jean-Marc Vanel wrote:
>>> > Hi
>>> >
>>> > I tested with 3.2.0.
>>> >
>>> > The short form for the CONSTRUCT query
>>> > https://www.w3.org/TR/sparql11-query/#constructWhere
>>> > works, at least syntactically ( I have nothing in the default graph
>>> in my
>>> > TDB ) :
>>> > CONSTRUCT WHERE
>>> > { ?X ?P ?O . }
>>> > LIMIT 10
>>> >
>>> > But adding GRAPH pattern gives a synyax error:
>>> > CONSTRUCT WHERE {
>>> > GRAPH ?G {
>>> > ?X ?P ?O .
>>> > }
>>> > } LIMIT 10
>>> >
>>> > Which does not occur e.g. with Virtuoso.
>>> >
>>> > org.apache.jena.query.QueryParseException: Encountered " "graph"
>>> "GRAPH ""
>>> > at line 2, column 1.
>>> > Was expecting one of:
>>> > <IRIref> ...
>>> > <PNAME_NS> ...
>>> > <PNAME_LN> ...
>>> > <BLANK_NODE_LABEL> ...
>>> > <VAR1> ...
>>> > <VAR2> ...
>>> > "true" ...
>>> > "false" ...
>>> > <INTEGER> ...
>>> > <DECIMAL> ...
>>> > <DOUBLE> ...
>>> > <INTEGER_POSITIVE> ...
>>> > <DECIMAL_POSITIVE> ...
>>> > <DOUBLE_POSITIVE> ...
>>> > <INTEGER_NEGATIVE> ...
>>> > <DECIMAL_NEGATIVE> ...
>>> > <DOUBLE_NEGATIVE> ...
>>> > <STRING_LITERAL1> ...
>>> > <STRING_LITERAL2> ...
>>> > <STRING_LITERAL_LONG1> ...
>>> > <STRING_LITERAL_LONG2> ...
>>> > "(" ...
>>> > <NIL> ...
>>> > "}" ...
>>> > "[" ...
>>> > <ANON> ...
>>> >
>>> > at
>>> > org.apache.jena.sparql.lang.ParserSPARQL11.perform(
>>> ParserSPARQL11.java:100)
>>> >
>>> >
>>>
>>>
>>>
>>>
>>>
>>>
>>
>>
>> --
>> Jean-Marc Vanel
>>
>> http://www.semantic-forms.cc:9111/display?displayuri=http://jmvanel.free.fr/jmv.rdf%23me
>> D�ductions SARL - Consulting, services, training,
>> Rule-based programming, Semantic Web
>> +33 (0)6 89 16 29 52
>> Twitter: @jmvanel , @jmvanel_fr ; chat: irc://irc.freenode.net#eulergui
>>
>
Re: Likely bug: short form for the CONSTRUCT query + GRAPH => syntax error
Posted by Martynas Jusevičius <ma...@graphity.org>.
It has to be a basic pattern:
https://www.w3.org/TR/sparql11-query/#constructWhere
On Thu, 16 Feb 2017 at 21.31, Jean-Marc Vanel <je...@gmail.com>
wrote:
> Indeed adding syntaxARQ brings a progress:
> QueryFactory.create(query, Syntax.syntaxARQ)
>
> GRAPH is tolerated,
> but OPTIONAL is not:
>
> Exception in thread "main" org.apache.jena.query.QueryParseException:
> Encountered " "optional" "OPTIONAL "" at line 9, column 11.
> Was expecting one of:
> <IRIref> ...
> <PNAME_NS> ...
> <PNAME_LN> ...
> <BLANK_NODE_LABEL> ...
> <VAR1> ...
> <VAR2> ...
> "true" ...
> "false" ...
> <INTEGER> ...
> <DECIMAL> ...
> <DOUBLE> ...
> <INTEGER_POSITIVE> ...
> <DECIMAL_POSITIVE> ...
> <DOUBLE_POSITIVE> ...
> <INTEGER_NEGATIVE> ...
> <DECIMAL_NEGATIVE> ...
> <DOUBLE_NEGATIVE> ...
> <STRING_LITERAL1> ...
> <STRING_LITERAL2> ...
> <STRING_LITERAL_LONG1> ...
> <STRING_LITERAL_LONG2> ...
> "(" ...
> <NIL> ...
> "}" ...
> "[" ...
> <ANON> ...
>
> at
> org.apache.jena.sparql.lang.ParserSPARQL11.perform(ParserSPARQL11.java:100)
> at
> org.apache.jena.sparql.lang.ParserSPARQL11.parse$(ParserSPARQL11.java:52)
>
>
>
> 2017-02-16 17:54 GMT+01:00 Rob Vesse <rv...@dotnetrdf.org>:
>
> > As a general comment the short form of construct is very constrained.
> > Anything other than that simple triple patterns is illegal in the short
> form
> >
> > Rob
> >
> > On 16/02/2017 16:45, "Andy Seaborne" <an...@apache.org> wrote:
> >
> > Hi,
> >
> > The result of a CONSTRUCT is an RDF graph and the template must be a
> > "triples template"
> >
> > [10] ConstructQuery ::=
> > 'CONSTRUCT' ... 'WHERE' '{' TriplesTemplate? '}' ...
> >
> > and
> >
> > [52] TriplesTemplate ::=
> > TriplesSameSubject ( '.' TriplesTemplate? )?
> >
> > No GRAPH.
> >
> > Jena accepts CONSTRUCT WHERE { GRAPH .... }
> > in extended mode (Syntax.syntaxARQ) and returns a Dataset.
> >
> > Andy
> >
> >
> > On 16/02/17 14:52, Jean-Marc Vanel wrote:
> > > Hi
> > >
> > > I tested with 3.2.0.
> > >
> > > The short form for the CONSTRUCT query
> > > https://www.w3.org/TR/sparql11-query/#constructWhere
> > > works, at least syntactically ( I have nothing in the default graph
> > in my
> > > TDB ) :
> > > CONSTRUCT WHERE
> > > { ?X ?P ?O . }
> > > LIMIT 10
> > >
> > > But adding GRAPH pattern gives a synyax error:
> > > CONSTRUCT WHERE {
> > > GRAPH ?G {
> > > ?X ?P ?O .
> > > }
> > > } LIMIT 10
> > >
> > > Which does not occur e.g. with Virtuoso.
> > >
> > > org.apache.jena.query.QueryParseException: Encountered " "graph"
> > "GRAPH ""
> > > at line 2, column 1.
> > > Was expecting one of:
> > > <IRIref> ...
> > > <PNAME_NS> ...
> > > <PNAME_LN> ...
> > > <BLANK_NODE_LABEL> ...
> > > <VAR1> ...
> > > <VAR2> ...
> > > "true" ...
> > > "false" ...
> > > <INTEGER> ...
> > > <DECIMAL> ...
> > > <DOUBLE> ...
> > > <INTEGER_POSITIVE> ...
> > > <DECIMAL_POSITIVE> ...
> > > <DOUBLE_POSITIVE> ...
> > > <INTEGER_NEGATIVE> ...
> > > <DECIMAL_NEGATIVE> ...
> > > <DOUBLE_NEGATIVE> ...
> > > <STRING_LITERAL1> ...
> > > <STRING_LITERAL2> ...
> > > <STRING_LITERAL_LONG1> ...
> > > <STRING_LITERAL_LONG2> ...
> > > "(" ...
> > > <NIL> ...
> > > "}" ...
> > > "[" ...
> > > <ANON> ...
> > >
> > > at
> > > org.apache.jena.sparql.lang.ParserSPARQL11.perform(
> > ParserSPARQL11.java:100)
> > >
> > >
> >
> >
> >
> >
> >
> >
>
>
> --
> Jean-Marc Vanel
>
> http://www.semantic-forms.cc:9111/display?displayuri=http://jmvanel.free.fr/jmv.rdf%23me
> Déductions SARL - Consulting, services, training,
> Rule-based programming, Semantic Web
> +33 (0)6 89 16 29 52
> Twitter: @jmvanel , @jmvanel_fr ; chat: irc://irc.freenode.net#eulergui
>
Re: Likely bug: short form for the CONSTRUCT query + GRAPH => syntax error
Posted by Jean-Marc Vanel <je...@gmail.com>.
Indeed adding syntaxARQ brings a progress:
QueryFactory.create(query, Syntax.syntaxARQ)
GRAPH is tolerated,
but OPTIONAL is not:
Exception in thread "main" org.apache.jena.query.QueryParseException:
Encountered " "optional" "OPTIONAL "" at line 9, column 11.
Was expecting one of:
<IRIref> ...
<PNAME_NS> ...
<PNAME_LN> ...
<BLANK_NODE_LABEL> ...
<VAR1> ...
<VAR2> ...
"true" ...
"false" ...
<INTEGER> ...
<DECIMAL> ...
<DOUBLE> ...
<INTEGER_POSITIVE> ...
<DECIMAL_POSITIVE> ...
<DOUBLE_POSITIVE> ...
<INTEGER_NEGATIVE> ...
<DECIMAL_NEGATIVE> ...
<DOUBLE_NEGATIVE> ...
<STRING_LITERAL1> ...
<STRING_LITERAL2> ...
<STRING_LITERAL_LONG1> ...
<STRING_LITERAL_LONG2> ...
"(" ...
<NIL> ...
"}" ...
"[" ...
<ANON> ...
at
org.apache.jena.sparql.lang.ParserSPARQL11.perform(ParserSPARQL11.java:100)
at
org.apache.jena.sparql.lang.ParserSPARQL11.parse$(ParserSPARQL11.java:52)
2017-02-16 17:54 GMT+01:00 Rob Vesse <rv...@dotnetrdf.org>:
> As a general comment the short form of construct is very constrained.
> Anything other than that simple triple patterns is illegal in the short form
>
> Rob
>
> On 16/02/2017 16:45, "Andy Seaborne" <an...@apache.org> wrote:
>
> Hi,
>
> The result of a CONSTRUCT is an RDF graph and the template must be a
> "triples template"
>
> [10] ConstructQuery ::=
> 'CONSTRUCT' ... 'WHERE' '{' TriplesTemplate? '}' ...
>
> and
>
> [52] TriplesTemplate ::=
> TriplesSameSubject ( '.' TriplesTemplate? )?
>
> No GRAPH.
>
> Jena accepts CONSTRUCT WHERE { GRAPH .... }
> in extended mode (Syntax.syntaxARQ) and returns a Dataset.
>
> Andy
>
>
> On 16/02/17 14:52, Jean-Marc Vanel wrote:
> > Hi
> >
> > I tested with 3.2.0.
> >
> > The short form for the CONSTRUCT query
> > https://www.w3.org/TR/sparql11-query/#constructWhere
> > works, at least syntactically ( I have nothing in the default graph
> in my
> > TDB ) :
> > CONSTRUCT WHERE
> > { ?X ?P ?O . }
> > LIMIT 10
> >
> > But adding GRAPH pattern gives a synyax error:
> > CONSTRUCT WHERE {
> > GRAPH ?G {
> > ?X ?P ?O .
> > }
> > } LIMIT 10
> >
> > Which does not occur e.g. with Virtuoso.
> >
> > org.apache.jena.query.QueryParseException: Encountered " "graph"
> "GRAPH ""
> > at line 2, column 1.
> > Was expecting one of:
> > <IRIref> ...
> > <PNAME_NS> ...
> > <PNAME_LN> ...
> > <BLANK_NODE_LABEL> ...
> > <VAR1> ...
> > <VAR2> ...
> > "true" ...
> > "false" ...
> > <INTEGER> ...
> > <DECIMAL> ...
> > <DOUBLE> ...
> > <INTEGER_POSITIVE> ...
> > <DECIMAL_POSITIVE> ...
> > <DOUBLE_POSITIVE> ...
> > <INTEGER_NEGATIVE> ...
> > <DECIMAL_NEGATIVE> ...
> > <DOUBLE_NEGATIVE> ...
> > <STRING_LITERAL1> ...
> > <STRING_LITERAL2> ...
> > <STRING_LITERAL_LONG1> ...
> > <STRING_LITERAL_LONG2> ...
> > "(" ...
> > <NIL> ...
> > "}" ...
> > "[" ...
> > <ANON> ...
> >
> > at
> > org.apache.jena.sparql.lang.ParserSPARQL11.perform(
> ParserSPARQL11.java:100)
> >
> >
>
>
>
>
>
>
--
Jean-Marc Vanel
http://www.semantic-forms.cc:9111/display?displayuri=http://jmvanel.free.fr/jmv.rdf%23me
Déductions SARL - Consulting, services, training,
Rule-based programming, Semantic Web
+33 (0)6 89 16 29 52
Twitter: @jmvanel , @jmvanel_fr ; chat: irc://irc.freenode.net#eulergui
Re: Likely bug: short form for the CONSTRUCT query + GRAPH => syntax
error
Posted by Rob Vesse <rv...@dotnetrdf.org>.
As a general comment the short form of construct is very constrained. Anything other than that simple triple patterns is illegal in the short form
Rob
On 16/02/2017 16:45, "Andy Seaborne" <an...@apache.org> wrote:
Hi,
The result of a CONSTRUCT is an RDF graph and the template must be a
"triples template"
[10] ConstructQuery ::=
'CONSTRUCT' ... 'WHERE' '{' TriplesTemplate? '}' ...
and
[52] TriplesTemplate ::=
TriplesSameSubject ( '.' TriplesTemplate? )?
No GRAPH.
Jena accepts CONSTRUCT WHERE { GRAPH .... }
in extended mode (Syntax.syntaxARQ) and returns a Dataset.
Andy
On 16/02/17 14:52, Jean-Marc Vanel wrote:
> Hi
>
> I tested with 3.2.0.
>
> The short form for the CONSTRUCT query
> https://www.w3.org/TR/sparql11-query/#constructWhere
> works, at least syntactically ( I have nothing in the default graph in my
> TDB ) :
> CONSTRUCT WHERE
> { ?X ?P ?O . }
> LIMIT 10
>
> But adding GRAPH pattern gives a synyax error:
> CONSTRUCT WHERE {
> GRAPH ?G {
> ?X ?P ?O .
> }
> } LIMIT 10
>
> Which does not occur e.g. with Virtuoso.
>
> org.apache.jena.query.QueryParseException: Encountered " "graph" "GRAPH ""
> at line 2, column 1.
> Was expecting one of:
> <IRIref> ...
> <PNAME_NS> ...
> <PNAME_LN> ...
> <BLANK_NODE_LABEL> ...
> <VAR1> ...
> <VAR2> ...
> "true" ...
> "false" ...
> <INTEGER> ...
> <DECIMAL> ...
> <DOUBLE> ...
> <INTEGER_POSITIVE> ...
> <DECIMAL_POSITIVE> ...
> <DOUBLE_POSITIVE> ...
> <INTEGER_NEGATIVE> ...
> <DECIMAL_NEGATIVE> ...
> <DOUBLE_NEGATIVE> ...
> <STRING_LITERAL1> ...
> <STRING_LITERAL2> ...
> <STRING_LITERAL_LONG1> ...
> <STRING_LITERAL_LONG2> ...
> "(" ...
> <NIL> ...
> "}" ...
> "[" ...
> <ANON> ...
>
> at
> org.apache.jena.sparql.lang.ParserSPARQL11.perform(ParserSPARQL11.java:100)
>
>
Re: Likely bug: short form for the CONSTRUCT query + GRAPH => syntax
error
Posted by Andy Seaborne <an...@apache.org>.
Hi,
The result of a CONSTRUCT is an RDF graph and the template must be a
"triples template"
[10] ConstructQuery ::=
'CONSTRUCT' ... 'WHERE' '{' TriplesTemplate? '}' ...
and
[52] TriplesTemplate ::=
TriplesSameSubject ( '.' TriplesTemplate? )?
No GRAPH.
Jena accepts CONSTRUCT WHERE { GRAPH .... }
in extended mode (Syntax.syntaxARQ) and returns a Dataset.
Andy
On 16/02/17 14:52, Jean-Marc Vanel wrote:
> Hi
>
> I tested with 3.2.0.
>
> The short form for the CONSTRUCT query
> https://www.w3.org/TR/sparql11-query/#constructWhere
> works, at least syntactically ( I have nothing in the default graph in my
> TDB ) :
> CONSTRUCT WHERE
> { ?X ?P ?O . }
> LIMIT 10
>
> But adding GRAPH pattern gives a synyax error:
> CONSTRUCT WHERE {
> GRAPH ?G {
> ?X ?P ?O .
> }
> } LIMIT 10
>
> Which does not occur e.g. with Virtuoso.
>
> org.apache.jena.query.QueryParseException: Encountered " "graph" "GRAPH ""
> at line 2, column 1.
> Was expecting one of:
> <IRIref> ...
> <PNAME_NS> ...
> <PNAME_LN> ...
> <BLANK_NODE_LABEL> ...
> <VAR1> ...
> <VAR2> ...
> "true" ...
> "false" ...
> <INTEGER> ...
> <DECIMAL> ...
> <DOUBLE> ...
> <INTEGER_POSITIVE> ...
> <DECIMAL_POSITIVE> ...
> <DOUBLE_POSITIVE> ...
> <INTEGER_NEGATIVE> ...
> <DECIMAL_NEGATIVE> ...
> <DOUBLE_NEGATIVE> ...
> <STRING_LITERAL1> ...
> <STRING_LITERAL2> ...
> <STRING_LITERAL_LONG1> ...
> <STRING_LITERAL_LONG2> ...
> "(" ...
> <NIL> ...
> "}" ...
> "[" ...
> <ANON> ...
>
> at
> org.apache.jena.sparql.lang.ParserSPARQL11.perform(ParserSPARQL11.java:100)
>
>