I’m trying to understand the semantics and implementation of the VALUES clause,
specifically with respect to testing a “blacklist” of values.
I have used VALUES for whitelists, whereby I can match a bound variable to one
of the values:
VALUES ?WL ( a b c d)
FILTER ( ?V = ?WL)
This is nice, in that I can refer to ?WL in several graphs in a query that
UNIONs various graphs
{ stmt1 .
stmt2.
FILTER (?V = ?WL)
}
UNION
{ ….
FILTER (?W = ?WL)
}
….
What I’d like to do is to use a similar approach for blacklisting, where if the
value is in the VALUES list ?BL, the filter expression is false.
The obvious ( FILTER (?X != ?BL)) doesn’t work, as the semantics are wrong -
that is, if there’s just one item that’s not equal to ?X, the expression is
true.
Use of "NOT IN" doesn’t work, as there just one expression (?BL) to compare
against, and this reduces to the ?X != ?BL problem.
The only thing that’s worked for me is:
FILTER ( ?X NOT IN ( e, f, g, h, i))
It’s not as good, since the list has to be replicated in each context it’s
being used.
Is there something I’m missing ( usually is :-S ) or have I found the least bad
option?