Wednesday, August 12, 2009

Simpler SPARQL Results

SPARQL Results have two different, distinct and unnecessary ways of doings query results - one for SPARQL SELECT and one for SPARQL ASK (the whole SELECT vs ASK is worth pursuing too).

The section of a SPARQL SELECT XML result looks like:

...
<results>
<result>
<binding name="x"> ... </binding>
<binding name="hpage"> ... </binding>
</result>
...


An ASK result looks like:

...
<boolean>true</boolean>
...


The with the value inside the boolean either true or false (or possibly fred - depending on how you parse it - it would be nice to have an XSD). One set of results live in a results/result/binding and the other in a boolean. A simpler way to do it is just to use the absence or presence of a binding within the results/result.

For true:

<results>
<result>
<binding/>
</result>
</results>


For false:

...
<results>
<result/>
</results>
...


The JSON looks pretty much the same:

{
...
bindings : [{}] // true
bindings : [] // false
}


No parsing of true or false or having special cases for code producing or consuming SPARQL different kinds of answers.
Post a Comment