You are missing that ?country
has a rdf:type
of dbo:Country
and not dbo:longName
. The right query should be:
PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX dbr: <http://dbpedia.org/resource/>
SELECT ?country ?capital
WHERE {
?x a dbo:Country.
?x dbo:longName ?country.
?x dbp:capital ?capital
}
Update
Based on your comment you want the URI's of the country and their capital. Therefore, you don't need dbo:longName
, because you don't want the country label name. You will select the instances:
PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX dbr: <http://dbpedia.org/resource/>
SELECT ?country ?capital
WHERE {
?country a dbo:Country.
?country dbo:capital ?capital
}
Note that results will bring countries that are extinct. If you want to filter countries that have ended, you should get this result with:
PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX dbr: <http://dbpedia.org/resource/>
SELECT ?country ?capital
WHERE {
?country a dbo:Country.
?country dbo:capital ?capital.
FILTER NOT EXISTS { ?country dbo:dissolutionYear ?yearEnd }
}
?country rdf:type dbo:longName
- does this make sense to you? – Tranquilize