Virtuoso 37000 Error SP030

5.8k views Asked by At

why is showing this error, i see in the sparql query is correct, i don't see any mistake in prefix.

PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#> 
PREFIX type: <http://dbpedia.org/class/yago/> 
PREFIX prop: <http://dbpedia.org/property/>

SELECT ?country_name ?population 
WHERE { ?country rdf:type dbpedia-owl:Country;
rdfs:label ?country_name ; 
prop:populationEstimate ?population . 
FILTER (?population > 2334456) . 
FILTER ( lang(?country_name) = 'en')}

Error: Virtuoso 37000 Error SP030: SPARQL compiler, line 1: Missing in PREFIX declaration at '<' before 'http:'

SPARQL query: define sql:big-data-const 0 define input:default-graph-uri http://dbpedia.org PREFIX rdfs:

1

There are 1 answers

3
Joshua Taylor On BEST ANSWER

The query you've shown us might not be the same as the query you're actually running. First, the fact that the error message says "line 1" makes me wonder whether you've actually got the query run all onto one line. That can make it easy to get typo problems.

When I put your query into sparql.org's query validator, I do get a syntax error, because there's no prefix defined for rdf:. This is an error:

Line 7, column 18: Unresolved prefixed name: rdf:type

That said, the interactive web interface to the DBpedia endpoint includes some predefined namespace prefixes, and if you paste the query from the question into the web interface, it works just fine:

PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#> 
PREFIX type: <http://dbpedia.org/class/yago/> 
PREFIX prop: <http://dbpedia.org/property/>

SELECT ?country_name ?population 
WHERE { ?country rdf:type dbpedia-owl:Country;
rdfs:label ?country_name ; 
prop:populationEstimate ?population . 
FILTER (?population > 2334456) . 
FILTER ( lang(?country_name) = 'en')}

SPARQL results

I like to use the prefixes that DBpedia defines, since it makes copying and pasting easier, so I've used the prefix dbpprop: instead of prop:. I've also used langMatches instead of lang(…) = …, because it works with regional variants of languages, whereas the latter won't. I ended up with this query:

select ?country_name ?population where {
  ?country rdf:type dbpedia-owl:Country ;
           rdfs:label ?country_name ; 
           dbpprop:populationEstimate ?population . 
  filter (?population > 2334456) 
  filter langMatches(lang(?country_name),'en')
}

SPARQL results