0

how can get the value name of the capital city not the URI from this query

SELECT ?capital 
WHERE { <http://dbpedia.org/resource/Germany><http://dbpedia.org/ontology/capital> ?capital}

In the above query I am getting the URI of the capital of germany .ie http://dbpedia.org/resource/berlin how can get Only the berlin not its URI

user3335188
  • 99
  • 1
  • 6
  • Duplicated at answers.semanticweb.com as http://answers.semanticweb.com/questions/27340/how-to-get-the-value-of-a-resource-which-is-a-propery-of-another-resource-in-sparql-query. – Joshua Taylor Apr 01 '14 at 18:29

1 Answers1

3

The value you want is actually the value of the RDFS label property. If you're using the public DBpedia SPARQL endpoint, then you can use a query like this:

select ?label where {
  dbpedia:Germany dbpedia-owl:capital/rdfs:label ?label .
  filter langMatches(lang(?label),"en")
}

The property path dbpedia-owl:capital/rdfs:label means that you're getting the capital of Germany, and then getting the label of that. The filter expression lets you select just the English label of the resource. You can remove this filter, of course, but you'll get multiple results, since the resource has labels in different languages.

Joshua Taylor
  • 84,998
  • 9
  • 154
  • 353
  • Thank you. please why the query does not work on other countries like – user3335188 Apr 01 '14 at 22:47
  • 1
    like what? I think there is something missing from your comment. – Joshua Taylor Apr 02 '14 at 02:19
  • @user3335188 I'm not sure what other countries you were talking about. Its possible, I suppose, that some countries don't have capitals, but without knowing which ones you're asking about, I can be of much more help… – Joshua Taylor Apr 02 '14 at 13:48
  • thank you. I am querying Dbpedia using http://dbpedia.org/sparql end ponit in Javascript. it is really misbehaving sometimes it respond some times not. example yesterday is not responding for India e.t.c. today is not responding for Niger, Ethopia. Thank you never mind about. what is the efficient way to query Dbpedia for web application? – user3335188 Apr 02 '14 at 16:00
  • @user3335188 The DBpedia endpoint is often a bit unreliable; it's easy to encounter timeouts, and the system is often down for maintenance. It's important to check by visiting dbpedia.org/sparql manually. Just because a javascript driven query crashes or doesn't return results doesn't mean that there's necessarily something wrong with your query; the server could be down. – Joshua Taylor Apr 02 '14 at 16:06
  • :Is there any way that I can download the whole dbpedia data? will the same SPARQL query format work on the data set? i.e dbpedia-owl: – user3335188 Apr 04 '14 at 17:09