W3C home > Mailing lists > Public > public-sparql-dev@w3.org > January to March 2008

Re: Is there a SPARQL way to...

From: Leigh Dodds <leigh@ldodds.com>
Date: Fri, 1 Feb 2008 20:39:28 +0000
Message-ID: <4393527c0802011239i62334750pf9c624afbd6259b@mail.gmail.com>
To: "Lee Feigenbaum" <lee@thefigtrees.net>
Cc: "Richard Newman" <rnewman@franz.com>, "Max Voelkel" <voelkel@fzi.de>, public-sparql-dev@w3.org

> This should work:
>
> SELECT ?x {
>    ?x a ex:A .
>    OPTIONAL {
>      ?x a ?type .
>      FILTER(?type != ex:A)
>    }
>    FILTER(!bound(?type))
> }
>
> The OPTIONAL here tries to find a different type for the same resource
> (?x). If it succeeds then ?type is bound to a second class, so we filter
> out that case at the top-level.

And it does. I just ran it twinkle and it produces the expected
single result.

Nice work. I spent a long time scratching my head with that one.
Didn't occur to me to split the FILTERs into the separate OPTIONAL
patterns.

Fun!

L.
Received on Friday, 1 February 2008 20:39:41 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 1 February 2008 20:39:41 GMT