6

I am trying to query the RDF Data from linkedgeodata.org for States within a Country. In RDF it is represented as such:

<http://linkedgeodata.org/triplify/node1055351027>  <http://linkedgeodata.org/property/is_in%3Acountry> "LT" .

As you might notice, the predicate contains an escaped colon, so "%3A" instead of ":" I was not able to find a suitable SPARQL query for this, these are some of my attempts

?node lgdp:is_in "LT".
?node lgdp:is_in:country "LT".
?node lgdp:is_in%3Acountry "LT".
?node lgdp:is_in\u003Acountry "LT".
?node lgdp:is_in"\u003A"country "LT".

I am using the opensource version of virtuoso as my triple store, this is the errormessage I receive with all except the first form:

    Virtuoso 37000 Error SP030: SPARQL compiler, line 0: Invalid character in SPARQL expression at '\'

SPARQL query:
define sql:big-data-const 0 
#output-format:text/html
define input:default-graph-uri  PREFIX lgdo: 
PREFIX lgdp: 
PREFIX lgd: 
PREFIX pos: 
PREFIX rdf: 

SELECT ?node, ?label
Where {
 ?node a lgdo:State .
 ?node lgdp:is_in\u003Acountry "LT".
 ?node rdfs:label ?label .
} 
svick
  • 236,525
  • 50
  • 385
  • 514
Markus
  • 295
  • 4
  • 12

1 Answers1

7

Characters encoded with % are not allowed when using namespaces, in this case you'll have to use the full predicate directly (without the namespace). The following query works:

Prefix lgdo:<http://linkedgeodata.org/ontology/> 
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?node, ?label
Where {
 ?node a lgdo:State .
 ?node <http://linkedgeodata.org/property/is_in%3Acountry> "LT".
 ?node rdfs:label ?label
}

see the results here.

Manuel Salvadores
  • 16,287
  • 5
  • 37
  • 56
  • 2
    As Manuel states there are some URIs that you just can't compress into QName style notation and for these you will always have to use full URIs. Ideally people creating data should avoid creating URIs that will have this problem – RobV Apr 29 '11 at 09:00