On 16/02/17 20:37, Martynas Jusevičius 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 <[email protected]>
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 <[email protected]>:
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" <[email protected]> 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