Hi Lee !

Here are queries demonstrating the use of SPARQL CONSTRUCT for data transformation between heterogeneous vocabularies. The following queries allow to transform FOAF resources into vCard ones:

PREFIX vCard: http://www.w3.org/2001/vcard-rdf/3.0#
PREFIX foaf: http://xmlns.com/foaf/0.1/

CONSTRUCT { ?X vCard:FN ?name . }
WHERE { ?X foaf:name ?name . FILTER isLiteral(?name) }

CONSTRUCT {?X vCard:N _:a .
           _:a vCard:Family ?fname .
           _:a vCard:Given ?gname .}
WHERE { ?X foaf:firstName ?gname .
        ?X foaf:surname ?fname . }

CONSTRUCT { ?X vCard:URL ?url . }
WHERE { ?X foaf:workplaceHomepage ?url . FILTER isURI(?url) }

CONSTRUCT { ?X vCard:URL ?url . }
WHERE { ?X foaf:homepage ?url . FILTER isURI(?url) }

CONSTRUCT { ?X vCard:TITLE ?title }
WHERE { ?X foaf:title ?title . FILTER ( isLiteral(?T1) }

CONSTRUCT { ?X vCard:ORG _:a .
            _:a vCard:Orgname ?name .
            _:a vCard:URL ?url . }
WHERE { ?X foaf:currentProject ?Y
        ?Y foaf:name ?name .
        ?Y foaf:homepage ?url . }

CONSTRUCT { ?X vCard:ORG _:a .
            _:a vCard:Orgname ?name .  }
WHERE { ?X foaf:Group ?Y
        ?Y foaf:name ?name . }

One can remark this is only a partial transformation. That's because the current SPARQL spec misses some features like aggregates and individual generation. We would like for example to express the following CONSTRUCT queries:

CONSTRUCT { ?X vCard:TEL _:a .
            _:a rdf:value fn:substring(?T1,5) .
            _:a a http://www.w3.org/2001/vcard-rdf/3.0#voice }
WHERE { ?X foaf:phone ?T1 .
      FILTER ( isURI(?T1) )

Removing the "tel:" prefix of vCard:TEL, or

CONSTRUCT { ?X vCard:EMAIL _:a .
            _:a rdf:value fn:concat("mailto:",?email) .
            _:a a http://www.w3.org/2001/vcard-rdf/3.0#internet }
WHERE { ?X foaf:mbox ?email . }

adding the mailto: prefix to the vCard:EMAIL.

This is not possible in the current SPARQL spec. Our SPARQL++ [1] extension tackle this. Maybe a future recommendation ? ;)

Cheers,
François

[1]http://www.scharffe.fr/pub/sparql++-for-mapping-between-rdf-vocabularies-ODBASE-2007.pdf


Lee Feigenbaum wrote:

Hi everyone,

I'm putting together a "SPARQL by Example" tutorial, which is, as the name suggests, a step-by-step introduction to SPARQL taught almost entirely through complete, runnable SPARQL queries.

So far, I've gathered a great deal of example queries myself, but I know that many subscribers to these lists probably have favorite queries of their own that you might be willing to share with me.

I'm looking for:

1) SPARQL queries
2) ...that can be run by anyone (no private data sets)
3a)...either by running the query against a public SPARQL endpoint
3b)...or by using a public SPARQL endpoint that will fetch HTTP-accessible RDF data (e.g. sparql.org or demo.openlinksw.com)
4) ...that answers a real* question
5) ...and that is fun!**

* real is in the eye of the beholder, I imagine, but I'm not looking for "finds the predicates that relate ex:s and ex:o in this sample RDF graph"

** fun is also in the eye of the beholder. fun can be a query on fun data; a clever query that may illustrate a particular SPARQL construct ("trick"); a query that integrates interesting information; a query with surprising results; etc.

thanks to anyone who is able to contribute!
Lee

PS I plan to make the tutorial slides available online under an appropriate CC license once they are completed.




begin:vcard
fn;quoted-printable:Fran=C3=A7ois Scharffe
n;quoted-printable:Scharffe;Fran=C3=A7ois
org:University of Innsbruck;DERI
adr:21a Techniker-Strasse;;ICT Building, 2nd floor;Innsbruck;Tirol;6020;Austria
email;internet:[EMAIL PROTECTED]
title:Phd Student/ Researcher/ Teaching Assistant
tel;work:0043 512 507 6448
tel;fax:0043 512 507 9872
tel;home:don't have
tel;cell:0043 650 72 31 408
note;quoted-printable:my home page:=0D=0A=
	http://www.scharffe.fr
x-mozilla-html:FALSE
url:http://www.sti2.at
version:2.1
end:vcard

Reply via email to