rdfs:label ?lbl . ?sub a foaf:Person" /> rdfs:label ?lbl . ?sub a foaf:Person" /> rdfs:label ?lbl . ?sub a foaf:Person"/>

Escaping quotes in SPARQL

36 Views Asked by At

How do I escape quotes in this SPARQL query?

SELECT * WHERE { <http://dbpedia.org/resource/Andre_\"Dede\"_Sabino> rdfs:label ?lbl . ?sub a foaf:Person . ?sub rdfs:label ?lbl . optional {?sub dbo:birthDate ?birthDate .} optional {?sub dbo:birthPlace ?birthPlace . ?birthPlace a dbo:Location } optional {?sub dbo:birthPlace ?birthPlace2 .} ?sub dbo:abstract ?abstract . filter(langMatches(lang(?lbl), "en")) filter(langMatches(lang(?abstract ), "en")) } LIMIT 10

I have tried "" and \" and '.

1

There are 1 best solutions below

0
Stefan - brox IT-Solutions On BEST ANSWER

The quote character (") is not allowed in IRIs (in general, not just specifically in SPARQL). It has to be percent-encoded as %22.

So the IRI would not be

http://dbpedia.org/resource/Andre_"Dede"_Sabino

but

http://dbpedia.org/resource/Andre_%22Dede%22_Sabino

(Browsers typically display the unencoded form of the IRI in the address bar, but when copy-pasting it, you should get the percent-encoded form.)


If you need a quote character inside a string value in SPARQL, you can encode it with a backslash:

?person schema:name "Andre \"Dede\" Sabino" .