Re: SELECTing s properties in the same query

Sat, 15 Apr 2017 05:17:30 -0700

Jena's DESCRIBE behavior is pluggable. [1] If you can live with one "hop" on 
bnode traversal, you can use a plain query with isBlank. I'm sure this could be 
written better, but something like:

CONSTRUCT { ?sub ?pred ?obj } 

WHERE { 

  {  VALUES ?sub { <myuri> }
     ?sub ?pred ?obj . }
UNION
   { <myuri> ?somepred ?sub . 
    ?sub ?pred ?obj.  
    FILTER isBlank(?sub) }
 }

The legs account one for properties directly on the resource and the other for 
properties on bnodes connected to the resource. If you may have bnodes 
connecting to bnodes, you can also iterate a query like that to get the 
closure. For most people, one "hop" is likely enough.

---
A. Soroka
The University of Virginia Library

[1] https://jena.apache.org/documentation/query/extension.html#describe-handlers

> On Apr 15, 2017, at 5:58 AM, james anderson <ja...@dydra.com> wrote:
> 
> good afternoon;
> 
>> On 2017-04-15, at 11:43, Laura Morales <laure...@mail.com> wrote:
>> 
>>> Blank node closure is non-trivial
>> 
>> wouldn't be this the same problem with URLs as well?
> 
> yes, in general.
> 
>> For example if a node is pointing to another resource's URL and I want to 
>> retrieve some properties of that linked resource from the same query?
> 
> although one often sees sparql’s ‘describe’ treated with antiseptic isolation 
> gloves, there is a thorough description of how one might implement it[1], 
> which is followed in various respects in several sparql implementations.
> by this approach, the distinction between iri and blank nodes bounds the 
> description.
> 
> best regards, from berlin,
> - - -
> [1] : https://www.w3.org/Submission/CBD/
> - - -
> 
> 

Reply via email to