Hi,
I am using SPARQL CONSTRUCT queries to derive a dataset (from Geonames, DBPedia
and, eventually, other data sources) of all Italian regions, provinces and 
'comuni'.

Italy is divided in 20 regions. A region can be divided in its provinces. There
are 110 provinces in Italy. Finally, a province can have 'comuni' (or other
smaller administrative entities). There are 8094 of these in Italy (according to
Geonames).

This is a fragment of my SPARQL CONSTRUCT query:

----
PREFIX italy:  <http://example.com/italy/>
...
CONSTRUCT {
  ?region_uri rdf:type italy:Region .
  ?region_uri rdfs:label ?region .
  ?region_uri italy:contains ?p .

  ?province_uri rdf:type italy:Province .
  ?province_uri rdfs:label ?province .
  ?province_uri italy:contains ?comune_uri .
  ?province_uri italy:isContained ?region_uri .

  ?comune_uri rdf:type italy:Comune .
  ?comune_uri rdfs:label ?comune .
  ?comune_uri italy:isContained ?province_uri .
  ...
} WHERE {
  ...
  BIND ( iri(concat("http://example.com/italy/";, lcase(?region))) AS 
?region_uri )
  BIND ( iri(concat("http://example.com/italy/";, lcase(?region), '/',
lcase(?province))) AS ?province_uri )
  BIND ( iri(concat("http://example.com/italy/";, lcase(?region), '/',
lcase(?province), '/', lcase(?comune))) AS ?comune_uri )
}
----

This is a fragment of what the query above generates, for 'Roncone' which is a
'comune' in the province of Trento which is a province in the 'Trentino-Alto
Adige' region:

----
<http://example.com/italy/regione autonoma trentino-alto adige/provincia di
trento/roncone>
      a       italy:Comune ;
      rdfs:label "Roncone" ;
      italy:isContained <http://example.com/italy/regione autonoma trentino-alto
adige/provincia di trento> .
----

All this works well, but I have not been able to strip out "regione autonoma"
and replace ' ' with '_' when I generate my new URIs.

This, instead, is what I'd like to achieve:

----
<http://example.com/italy/trentino-alto_adige/trento/roncone>
      a       italy:Comune ;
      rdfs:label "Roncone" ;
      italy:isContained <http://example.com/italy/trentino-alto_adige/trento> .
----

Or, if possible (even better) this:

----
italy:trentino-alto_adige/trento/roncone
      a       italy:Comune ;
      rdfs:label "Roncone" ;
      italy:isContained italy:trentino-alto_adige/trento .
----

Is this possible to do this with a SPARQL CONSTRUCT query without writing a new
SPARQL/ARQ function?
I searched in ARQ, but I did not find a 'replace' function. Is there one? Would
it be an useful addition?

Also, I know that URIs should be opaque, but I though it would help humans to
follow a pattern {ns} + {region}/{province}/{comune}. What do you think about 
this?

Do you have other suggestions (in addition to Geonames, DBPedia and Freebase) of
good datasets for geographical informations about Europe and/or Italy?

Last but not least, this message is probably not completely on-topic on the
jena-users mailing list. Are these type of messages (on SPARQL queries and/or
data modelling using RDF) fine on jena-users? If not, what would be a better
mailing list for this sort of questions (I have a few on 'cheese' :-))?

Thanks,
Paolo

Reply via email to