I was testing a simple conditional in SPARQL and it wasn't working. So I
went to the documentation and wrote the test conditional and it worked, but
do not understand why mine isn't working. The test conditional compares 2
integers and displays 2 strings. I augmented that test to have another
Another thing to keep in mind is that IF will return nothing if the
condition is returning unbound (fail). For example,
IF(strlen(?a) 0, 1, 2)
will return nothing if ?a is not a string - it will fail and return
unbound - not 2. A safer way of expressing this would be
IF(bound(?a)
Holger and Scott,
Thank you very much for looking at this. Scott, I tried the scoping (as per
your suggestion) and it didn't change anything. I must admit that I had not
thought to run the query debugger, but I do not really understand how it
works anyway.
Holger, I tried using bound(?res2) and
Jack; The problem may be that SPARQL's declarative nature does not
impose any ordering on its statements. One should be able to place
the statements in any order and the result will be the same.
In your case, you need to make sure the ?res1 and ?res2 binding are