Aaginor
Aaginor

Reputation: 4782

Dealing with special characters in SPARQL-Filter expressions

I access the SPARQL-Endpoint of dbpedia[1] to get the URI for a given city. I use the following query to achieve this:

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX dbpedia: <http://dbpedia.org/ontology/> 
select distinct * where 
  {?uri rdfs:label ?label. 
  FILTER (REGEX(STR(?label), "^Köln$", "i")). 
  ?uri a dbpedia:PopulatedPlace.
}

If I query for a city without a german umlaut, everything works fine, but if there is an umlaut, I get nothing. When executing this query via code, I even get a 406-error (not acceptable)

Any idea, how to deal with umlauts in a SPARQL-query against dbpedia?

Thanks in advance,
Frank

[1] http://dbpedia.org/sparql

Upvotes: 5

Views: 2230

Answers (1)

Spork
Spork

Reputation: 1651

There seems to be a bug in the handling of your character, maybe in transport, or otherwise. It does work when you just write it down in unicode hex for ö, like so:

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX dbpedia: <http://dbpedia.org/ontology/> 
select distinct * where 
  {?uri rdfs:label ?label. 
  FILTER (REGEX(STR(?label), "^K\u00F6ln$")). 
  ?uri a dbpedia:PopulatedPlace.
}

Edit: I see now that this isn't working with the 'i' flag. Documentation suggests the 'u' flag would be applicable here.

Upvotes: 4

Related Questions