Hi all-

Assume I have a data set which among other things has triples like:

my:entity1 my:hasLabelSet my:labelSet1
my:labelSet1 my:hasLabel "entity1"
my:labelSet1 my:hasLabel "entity #1"
my:labelSet1 my:hasLabel "entity one"

my:entity2 my:hasLabelSet my:labelSet2

...etc.

and each entity has a bunch of other links which relate to actual semantics. When I query over this set, I want to arbitrarily pick exactly one of these labels, just to give it a human-readable name. Any one will do.

I've tried using a subquery like this:

SELECT ?entity ?arbitraryLabel
where
{
   ?entity my:hasFeature my:VeryImportantFeature.
   {
    SELECT ?arbitraryLabel
    {
      ?entity my:hasLabelSet ?labelSet.
      ?labelSet my:hasLabel ?arbitraryLabel.
    }
    LIMIT 1
   }
}

on the assumption that the variables in the main query are scoped in such a way that they are shared with the subquery.

But what I get is a listing like
entity1 "unrelated label 25"
entity2 "unrelated label 25"
entity3 "unrelated label 25"
.
.
.

Suggesting that ?entity in the subquery is being bound in a completely separate lexical environment from the ?entity in the main query.

So was I incorrect in my original assumption about scoping in subqueries, or is this a bug? If I am mistaken, I would appreciate any advice as to how to do this by some other means.

Thanks,


Reply via email to