How to reference a page that contains parenthesis in SPARQL

谁说胖子不能爱 提交于 2019-12-10 14:15:23

问题


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   
}


来源:https://stackoverflow.com/questions/31384952/how-to-reference-a-page-that-contains-parenthesis-in-sparql

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!