- From: Steve Harris <swh@ecs.soton.ac.uk>
- Date: Wed, 4 Jul 2007 15:28:47 +0100
- To: Jacek Kopecky <jacek.kopecky@deri.org>
- Cc: Danny Ayers <danny.ayers@gmail.com>, al@jku.at, semantic-web@w3.org
On 4 Jul 2007, at 14:50, Jacek Kopecky wrote: > Steve, good idea, that grouping. > Could it be extended for grouping (or arraying) deeper than 1 level? Probably, but then the syntax would get a bit funky. You could add an extension function to gather recursive bindings, but I their not supposed to bind variables in SPARQL. - Steve > Or even recursively? Could get interesting if every part could have > subparts that could have subparts etc. > > In that case I guess even CONSTRUCTXML would have to be extended, > something like: > > CONSTRUCTXML > <catalogue> > <product id="{?prodid}"> > {CONSTRUCTXML NAMED part > <part name="{?partname}"> > {CONSTRUCTXML REF part WITH ?prodid=?partname} > </part> > WHERE { ?prodid hasPart ?partName } > } > </product> > </catalogue> > WHERE { ?prodid rdf:type Product } > > And then it might have to deal with handling loops in the data. > > Best regards, > Jacek > > On Wed, 2007-07-04 at 14:12 +0100, Steve Harris wrote: >>> But the results table will be: >>> >>> 1 wheel >>> 1 engine >>> 1 chassis >>> 2 antenna >>> 2 receiver >> >> I've run into this problem a lot as well. I can imagine a SPARQL >> syntax extension like: >> >> SELECT DISTINCT ?prodid ?partname >> WHERE { ?prodid rdf:type :Product ; >> :hasPart ?partName . } >> GROUP BY ?prodid >> >> which could return something like: >> ... >> <result> >> <binding name="prodid"><literal>1</literal></binding> >> <binding name="partname"> >> <literal>wheel</literal> >> <literal>engine</literal> >> <literal>chassis</literal> >> </binding> >> </result> >> ... >> >> If you have it in that form it's a lot easier to do the kind of XSLT >> transforms we're talking about. >> >> That sort of trick may catch SQL users off-guard, it might be worth >> writing ARRAY(?partname) or similar. I think it would be pretty handy >> given the random and surprising cardinality that RDF predicates often >> have in the wild though. >> >> - Steve >> >
Received on Wednesday, 4 July 2007 14:33:26 UTC