Re: Is there a SPARQL way to...

> 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 UTC