In the answer to this question here, using SPARQL 1.1, I wanted to bind a new variable based on the value of an existing one. Specifically, I had calculated an ID for the day of the week such that 0 = Sunday, 1 = Monday, 2 = Tuesday, etc. Based on the binding for
Essentially, I want to code some traditional "cases" structure into SPARQL. Factoring out the day ID calculation for brevity (here hardcoded as Sunday), I tried:
So, concrete questions:
(NB: This was not my preferred design - I preferred the substitution semantics you expected.)
answered 25 Mar '12, 12:41
Here's what I know. That query wouldn't run at all against Virtuoso so I simplified the query slightly and set up a test case against a Jena in-memory model
This test case fails on the assertTrue() so that means no solutions are coming back.
I do get results if I (1) remove the FILTER or (2) write the following for the FILTER
so I guess that FILTER and BINDINGS don't work together in Jena the way you and I would expect them to. Perhaps this is a bug in Jena or perhaps we're not reading the SPARQL 1.1 spec correctly.
Note in a case like this, you can always write the old if-then-else ladder...
answered 25 Mar '12, 12:16