- From: Paul Gearon <gearon@ieee.org>
- Date: Wed, 23 Jun 2010 06:08:10 -0700
- To: Pierre-Antoine Champin <swlists-040405@champin.net>
- Cc: Andy Seaborne <andy.seaborne@talis.com>, Semantic Web <semantic-web@w3.org>
On Wed, Jun 23, 2010 at 3:59 AM, Pierre-Antoine Champin <swlists-040405@champin.net> wrote: > On 20/06/2010 13:23, Andy Seaborne wrote: >> >> >> On 19/06/2010 10:05 PM, Pat Hayes wrote: >>> >>> On Jun 19, 2010, at 11:54 AM, Andy Seaborne wrote: >>> >>>> >>>> >>>> On 17/06/2010 11:35 PM, Paul Gearon wrote: >>>>> The main problem with an RDF list is that there is no mechanism in >>>>> SPARQL to query or update them. SPARQL only allows you to form queries >>>>> that explicitly describe connections, while an arbitrary list can have >>>>> any number of elements down its length. That means that you can refer >>>>> to, say, the 2nd, 3rd, or 4th elements in the list, but there is no >>>>> way to refer to ALL the elements in the list, since you don't know how >>>>> long the list is. >>>>> >>>>> SPARQL 1.1 will fix this problem with "property paths". >>>> >>>> with >>>> >>>> { <list> rdf:rest*/rdf:first ?x } >>>> >>>> this is only a partial solution: >>>> >>>> 1/ Order in a list is not preserved >>> >>> ? Preserved by what? Lists in RDF have an order (that is, the elements >>> of the list are put into an order by the list.) What is it that doesn't >>> 'preserve' this? >> >> The SPARQL property path expression that Paul mentioned does not provide >> any guarantee on order of results returned, nor do further operations of >> the SPARQL algebra for graph patterns preserve order. SPARQL looses the >> ordering. It can't properly return lists either, only members of a list. > > By the way, is there a clean way in SPARQL to retrieve *all* items of an > rdf:Seq, which would preserve the order ? > > The only way I can think of involves FILTER, regex on URIs, and would > put item #11 before item #2... I have to check, but I believe that substring will be a function in SPARQL 1.1 (perhaps with a domain). Some triplestores already have this. Once you have it you can say something like: SELECT ?seq ?element WHERE { ?seq ?prop ?element FILTER regex(?prop, "^http://www.w3.org/1999/02/22-rdf-syntax-ns#_") } ORDER BY xsd:int(substring(?prop, 45)) (The rdf:_ string is 44 characters long) Regards, Paul Gearon
Received on Wednesday, 23 June 2010 13:08:43 UTC