W3C home > Mailing lists > Public > semantic-web@w3.org > April 2015

Easier SPARQL queries of ordered lists?

From: David Booth <david@dbooth.org>
Date: Tue, 14 Apr 2015 05:07:03 -0400
Message-ID: <552CD8B7.8090906@dbooth.org>
To: semantic-web <semantic-web@w3.org>
rdf:Lists are a pain for SPARQL queries, because it's hard to retain the 
list ordering when querying, even if it is possible[1].  To work around 
this problem, some list ontologies have been created[2][3], but I find 
them overly verbose for routine use.  The Jena ARQ library also has a 
feature that helps[4], but it is not standard SPARQL.

I'd like to propose a simpler convention that encodes each item as a 
(value index) pair, and a simple vocabulary to go with it.  For example, 
instead of writing this:

   PREFIX : <http://example/>
   :jane :likes (
         ) .

each item would have an explicit index, like this:

   PREFIX : <http://example/>
   :jane :likes
         ( "bananas" 0 ) ,
         ( "apples"  1 ) ,
         ( "oranges" 2 ) .

which can be easily queried like this, retaining order:

     :jane :likes ( ?item ?index ) .
   } ORDER BY ?index

There's a little more too.  I've written this up in a draft document:

I would be very interested in any comments or suggestions.  What do you 

David Booth

1. Standard SPARQL query of rdf:List that retains list order:

2. Ordered List Ontology:

3. Collections Ontology:

4. Jena ARQ list:index example:
Received on Tuesday, 14 April 2015 09:07:35 UTC

This archive was generated by hypermail 2.4.0 : Tuesday, 5 July 2022 08:45:42 UTC