Search code examples
sparqlrdfrdfsturtle-rdf

SPARQL RDF prefixing


Im wondering why I get a huge prefix on everything that is queried with SPARQL from my own ontology?

I'm quite new to all this, so I'm probably doing something wrong, but running this query

base <http://kasperrt/interests.ttl#>
prefix interests: <http://kasperrt.no/interests.ttl>

SELECT DISTINCT ?class ?s ?a
WHERE {
  ?s a ?class .
}
LIMIT 25
OFFSET 0

Why is everything prefixed with things like this http://www.semanticweb.org/kasperrt/ontologies/2017/10/untitled-ontology-7?

And why won't this query return anything?

base <http://kasperrt/interests.ttl#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix interests: <http://kasperrt.no/interests.ttl>

SELECT DISTINCT ?interest1 ?interest2 ?name1 ?name2
WHERE {
    ?interest1
        rdfs:label ?name1;
        interests:Location ?location1.

    ?interest2
        rdfs:label ?name2;
        interests:Location ?location2.


  filter(?location1 != ?location2)

}

Solution

  • The problem was as AKSW said, that the prefix declaration was defined wrong thus not returning any results in the query.

    The onotology IRI wasn't specified in the query. Remember to refactor with when using Protégé correctly (as Stanislav Kralin said).