How to reference a page that contains parenthesis

2019-06-21 04:03发布

问题:

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   
}

回答1:

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   
}


标签: python sparql