How to reference a page that contains parenthesis in SPARQL
Asked Answered
T

1

6

I am trying to lookup information regarding someone on Dbpedia but their name contains parenthesis in this case ending with _(musician) which leads to an error.

SELECT ?birthPlace
WHERE {
  dbpedia:Tom_Johnston_(musician) dbpprop:birthPlace ?birthPlace   
}
Tortoni answered 13/7, 2015 at 13:39 Comment(0)
P
7

Parentheses aren't legal in prefixed names, but you can just use the full URI instead:

SELECT ?birthPlace
WHERE {
    <http://dbpedia.org/resource/Tom_Johnston_(musician)> dbpprop:birthPlace ?birthPlace   
}

It's also possible to escape them using \:

SPARQL local names also allow the non-alphanumeric characters allowed in IRIs via backslash character escapes (e.g. ns:id\=123).

SELECT ?birthPlace
WHERE {
    dbpedia:Tom_Johnston_\(musician\) dbpprop:birthPlace ?birthPlace   
}
Popish answered 13/7, 2015 at 13:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.