I am using the Virtuoso SPARQL endpoint for DBpedia. I am having no issue running some test queries, but my issue is when I run on a query based on the foaf:name "literal"
of an entity. Here is my code below:
prefix db: <http://dbpedia.org/resource/>
prefix dbo: <http://dbpedia.org/ontology/>
prefix foaf: <http://xlms.com/foaf/0.1/>
SELECT ?capital WHERE{
?state dbo:capital ?capital .
?state foaf:name "State of Alaska"@en .
}
My logic is that by ?state dbo:capital ?capital
refers to the capital of a state within DBpedia owl ontology. ?state foaf:name "State of Alaska"@en
should match the variable ?state
up with the literal entity Alaska
. I am having no issue when my queries are controlled by variables that are not foaf:name
. I have looked up examples and can't see what the issue is with my syntax. Even when I edit the last line to --
?state a foaf:name "State of Alaska"@en .
-- the code continues to fail. I have looked up other examples and can't find my specific issue. It appears as if this code SHOULD return the capital for Alaska based on the foaf:name
Literal.
I found the answer. The key is to not add this prefix at the top
prefix foaf: <http://xlms.com/foaf/0.1/>
That should be replaced with the correct foaf:
prefix declaration:
prefix foaf: <http://xmlns.com/foaf/0.1/>
Or probably even skipped, since the foaf:
prefix is predefined .
So the query below actually works:
SELECT ?capital WHERE {
?state dbo:capital ?capital .
?state foaf:name "State of Alabama"@en .
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.