[Activerdf] query results metadata
Eric Hanson
elh at cs.pdx.edu
Wed Oct 4 20:49:44 IST 2006
Eyal Oren wrote:
> On 10/03/06/10/06 21:31 -0700, Eric Hanson wrote:
>> Hi all,
>> I'm using the Redland Adapter in the ActiveRDF 0.2. Is it possible to
>> get query results metadata like the number of rows returned, the column
>> names, etc? I'm guessing this is something you're addressing in the
>> next version but if there's a way to do it now that'd be cool.
> Hi,
>
> Currently indeed there is not such information, as we return simple
> arrays or single values. I could add this easily in the new
> development, but what would be the use exactly?
>
> First, the number of results you can get from results.size (it's an
> array), and the number of query bindings you should know since you asked
> the query yourselve? Or am I missing something here?
> Can you explain me the usage scenario?
Get size from the array -- that makes sense.
The other thing is the "column" names that a SPARQL query returns. I
want the user to be able to enter in an arbitrary query in form, and
then display the results as a table, with the column names labeled at
the top. So if I do:
SELECT ?s ?p ?o WHERE {?s ?p ?o}
It should generate a three-column table with
<tr>
<th>s</th>
<th>p</th>
<th>o</th>
</tr>
at the top.
Another use-case is generating SPARQL query results in JSON format. The
SPARQL JSON serialization [1] requires a "head" section that looks like:
{
"head": { "vars": [ "book" , "title" ]
} ,
...
}
Make sense? It might mean moving away from pure array results to a
QueryResults object or something, I don't know if you're down with that...
Thanks,
Eric
[1] http://www.w3.org/2001/sw/DataAccess/json-sparql/
More information about the Activerdf
mailing list