- From: Benjamin Nowack <bnowack@appmosphere.com>
- Date: Mon, 30 Jul 2007 10:19:12 +0200
- To: Garret Wilson <garret@globalmentor.com>, Harry Halpin <hhalpin@ibiblio.org>
- Cc: Semantic Web <semantic-web@w3.org>
On 27.07.2007 23:47:33, Garret Wilson wrote: > >Harry Halpin wrote: >> Is it indeed difficult or impossible to write a SPARQL query over >> rdf:List, particulary with the use of owl:sameAs as in: It's impossible to write a general SPARQL query to retrieve all entries of an unknown rdf:List. The use of owl:sameAs doesn't really have an additional effect on the complexity, though. >> Can someone tell me precisely why and if so, does rdf:Seq help? Containers don't form a deep path which has to be traversed. They are just, well, containers. Members are at the same level/depth which allows retrieving them with a single query pattern. I'll re-paste my earlier query. It works for any number/length of container-based "additional-names": [[ SELECT ?pos ?name WHERE { <#card4711> vcard:additional-names ?seq . ?seq ?pos ?name . } ORDER BY ?pos . ]] This is impossible for rdf:List. You need a different query for each number of names, e.g. (assuming lists built w/o "parseType=Collection", but with an explicit first+literal): 2 names: [[ SELECT ?name1 ?name2 WHERE { <#card4711> vcard:additional-names ?list1 . ?list1 rdf:first ?name1 . ?list1 rdf:rest ?list2 . ?list2 rdf:first ?name2 . } ]] 3 names: [[ SELECT ?name1 ?name2 ?name3 WHERE { <#card4711> vcard:additional-names ?list1 . ?list1 rdf:first ?name1 . ?list1 rdf:rest ?list2 . ?list2 rdf:first ?name2 . ?list2 rdf:rest ?list3 . ?list3 rdf:first ?name3 . } ]] etc. It *is* possible to construct a query that would work for, say 1-5 additional names, but that would be a really ugly beast with nested OPTIONALs (which aren't supported by all RDF stores and are slower than querying a simple container that uses a single blank node instead of one for each branch). The more practical approach is probably to iteratively extend the query until you hit an rdf:nil or no additional rdf:rest. Cheers, Benjamin -- Benjamin Nowack http://bnode.org/
Received on Monday, 30 July 2007 08:19:32 UTC