- From: Steve Harris <swh@ecs.soton.ac.uk>
- Date: Wed, 4 Jul 2007 14:12:20 +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 13:18, Jacek Kopecky wrote: > > Hi Andreas, Danny, all, > > I've tried SPARQL+XSLT, not to HTML, but to app-dependent XML. > My experience was that it's a limited approach. In this longish post > I first talk about my experience, then about my XSLT-based solution > and > then about what I would see as an optimal solution. > > So the idea was: use SPARQL SELECT to get the data that you need > and put > them in the XML variable binding results table (which may have been > the > wrong choice), then use XSLT to transform that to the target XML. > The necessary SPARQL results table vocabulary, however, made the XSLT > basically write-only, you wouldn't want to read or maintain such a > beast. > > Another problem is with repeating structures in the target XML. Let's > say I want to create something like this intentionally trivial XML: > > <catalog> > <product id="1"> > <part name="wheel"/> > <part name="engine"/> > <part name="chassis"/> > </product> > <product id="2"> > <part name="antenna"/> > <part name="receiver"/> > </product> > </catalog> > > The SPARQL could be > > SELECT ?prodid ?partname >> WHERE { ?prodid rdf:type Product ; >> hasPart ?partName . } > > 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 13:18:25 UTC