Claude,
Thanks for offering to help!
The expression:
(?a ?b ?c) :hasMagicProperty ?this .
Is SPARQL 1.1 syntactic sugar for:
_:b0 rdf:first ?c ;
rdf:rest rdf:nil .
_:b1 rdf:first ?b ;
rdf:rest _:b0 .
_:b2 rdf:first ?a ;
rdf:rest _:b1 ;
:hasMagicProperty ?this .
See the RDF Collections section of the spec:
http://www.w3.org/TR/2013/REC-sparql11-query-20130321/#collections
For my use case, I don't need to know about the expanded form; I just want to
render a SPARQL query that uses the "(?a ?b ?c)" list syntax.
In the example query, I am using a magic property to identify values of
"?this", based on a SPIN magic property which has 3 input arguments. I have
updated the SPARQL in my stackoverflow post slightly so the intent is more
clear.
I figured out a workaround, which uses "addWhere()" recursively to write out
the expanded form of the RDF collection construct (using the anonymous nodes,
as above).
I posted this workaround code as an answer on stackoverflow, but it's a stopgap
solution. A querybuilder enhancement to support the sugary list () syntax would
be awesome. =)
Please let me know if this gives you enough info.
James and Andy, thanks for your help, too.
Russell Morrisey
Java Developer | CLS Platform Team
[email protected]
cscglobal.com
Making Business Possible – Worldwide
-----Original Message-----
From: Andy Seaborne [mailto:[email protected]]
Sent: Wednesday, October 28, 2015 8:38 AM
To: [email protected]
Subject: Re: How do I build a SPARQL list input using jena querybuilder?
and to see the same locally,
qparse --print=op --file <query>
Andy
On 28/10/15 12:03, james anderson wrote:
> good morning;
>
>> On 2015-10-28, at 12:41, Claude Warren <[email protected]> wrote:
>>
>> I replied on stackoverflow but am wondering exactly how would ARQ
>> parse the statement
>>
>> SELECT * WHERE {
>> (?a ?b ?c) :hasMagicProperty ?result .
>> }
>
> sparql.org says, as to be expected:
>
> 1 (base <http://example/base/>
> 2 (prefix ((: <http://spinning/onwards>))
> 3 (bgp
> 4 (triple ??0 <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> ?a)
> 5 (triple ??0 <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> ??1)
> 6 (triple ??1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> ?b)
> 7 (triple ??1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> ??2)
> 8 (triple ??2 <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> ?c)
> 9 (triple ??2 <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest>
> <http://www.w3.org/1999/02/22-rdf-syntax-ns#nil>)
> 10 (triple ??0 :hasMagicProperty ?result)
> 11 )))
>
>>
>> what is the expected query?
>
> to find some sort of computed relation between a three-element list(s) and
> some other node.
>
>>
>>
>> On Tue, Oct 27, 2015 at 7:58 PM, Morrisey, Russell <
>> [email protected]> wrote:
>>
>>> I have a bunch of code that uses SelectBuilder to build up a complex
>>> SPARQL query. In my query, I want to use a SPIN magic property
>>> that’s invoked like this:
>>>
>>>
>>>
>>> (?a ?b ?c) :hasMagicProperty ?result .
>>>
>>>
>>>
>>> I can’t figure out how to represent the list syntax (?a ?b ?c) using
>>> SelectBuilder. I’ve tried several approaches using java lists,
>>> strings and trying to figure out RDFList, but I’m still struggling.
>>>
>>>
>>>
>>> I posted the problem in more detail on stackoverflow:
>>>
>>>
>>> http://stackoverflow.com/questions/33351102/how-to-i-build-a-sparql-
>>> list-input-using-jena-querybuilder
>>>
>>>
>>>
>>>
>>>
>>> *Russell Morrisey*
>>> *Java Developer | CLS Platform Team*
>>> *Phone* *302-636-5400 <302-636-5400> x62899*
>>>
>>> [email protected]
>>> cscglobal.com
>>>
>>> [image:
>>> http://wiki/download/attachments/13879359/CSC+logo+for+sig+line.jpg?
>>> version=1&modificationDate=1411058694237]
>>>
>>> *Making Business Possible – Worldwide*
>>>
>>> *New York Law Journal** Reader Rankings*
>>>
>>> *CSC named* *#1 for Entity Management* *and* *#1 for Matter
>>> Management*
>>> *by* *The New York Law Journal.* Click here
>>> <https://www.cscglobal.com/global/web/csc/nylj-rankings.html> *to
>>> learn
>>> more!*
>>>
>>>
>>>
>>> ------------------------------
>>>
>>> NOTICE: This e-mail and any attachments is intended only for use by
>>> the
>>> addressee(s) named herein and may contain legally privileged,
>>> proprietary or confidential information. If you are not the intended
>>> recipient of this e-mail, you are hereby notified that any
>>> dissemination, distribution or copying of this email, and any attachments
>>> thereto, is strictly prohibited.
>>> If you receive this email in error please immediately notify me via
>>> reply email or at (800) 927-9800 and permanently delete the original
>>> copy and any copy of any e-mail, and any printout.
>>>
>>
>>
>>
>> --
>> I like: Like Like - The likeliest place on the web
>> <http://like-like.xenei.com>
>> LinkedIn: http://www.linkedin.com/in/claudewarren
>
>
>
> ---
> james anderson | [email protected] | http://dydra.com
>
>
>
>
>
________________________________
NOTICE: This e-mail and any attachments is intended only for use by the
addressee(s) named herein and may contain legally privileged, proprietary or
confidential information. If you are not the intended recipient of this e-mail,
you are hereby notified that any dissemination, distribution or copying of this
email, and any attachments thereto, is strictly prohibited. If you receive this
email in error please immediately notify me via reply email or at (800)
927-9800 and permanently delete the original copy and any copy of any e-mail,
and any printout.