- From: David Booth <david@dbooth.org>
- Date: Tue, 14 Apr 2015 05:07:03 -0400
- 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 ( "bananas" "apples" "oranges" ) . 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: SELECT DISTINCT ?item { :jane :likes ( ?item ?index ) . } ORDER BY ?index There's a little more too. I've written this up in a draft document: http://goo.gl/8PNuAG I would be very interested in any comments or suggestions. What do you think? Thanks! David Booth References 1. Standard SPARQL query of rdf:List that retains list order: http://stackoverflow.com/questions/17523804/is-it-possible-to-get-the-position-of-an-element-in-an-rdf-collection-in-sparql/17530689#17530689 2. Ordered List Ontology: http://smiy.sourceforge.net/olo/spec/orderedlistontology.html 3. Collections Ontology: http://www.essepuntato.it/lode/owlapi/http://purl.org/co/ 4. Jena ARQ list:index example: http://stackoverflow.com/questions/17523804/is-it-possible-to-get-the-position-of-an-element-in-an-rdf-collection-in-sparql/17528290#17528290
Received on Tuesday, 14 April 2015 09:07:35 UTC