Open Daniele opened 6 years ago
What's the explicit datatype of the "Test" in the ontology? Would you be able to post the ontology please?
This happens when the Type field is left blank (this is allowed by Protégé and even set as the default option). Based on the OWL specification, I would expect the datatype to automatically be interpreted as rdf:PlainLiteral, and the query to work. I have also tried this query and it doesn't work either:
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT *
WHERE {
?a rdfs:label "Test"^^rdf:PlainLiteral .
}
The ontology is empty except for this one individual. You can find it here: TestOntology.txt
Thanks very much for the test case.
If the type field is left blank in Protege then the datatype for the literal is rdf:PlainLiteral
in OWL. I doubled checked the OWL file and this is indeed the case. In RDF 1.1 "Test"
is interpreted as an xsd:string
. The Protege SPARQL tab uses an old version of Sesame and I'm not sure what the tab does under the hood when parsing the query and translating the ontology to RDF in preparation for the query. This complicates things. Someone from the Protege team will investigate this and report back.
Just another comment... this works as expected in Snap-SPARQL, but that has its limitations.
I've just done some poking around and the Protege RDF library translates the literal in the assertion
AnnotationAssertion(rdfs:label :ind "Test"^^rdf:PlainLiteral)
into a literal types with xsd:string
This is exhibited with the following query:
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
SELECT *
WHERE {
?subject ?prop ?object .
BIND(DATATYPE(?object) AS ?dt)
}
Potentially offending line here
@Daniele Sorry about this, but have you tried this with 5.5.0-beta-8? With your ontology and your query I get back one result with the individual IRI bound to ?a
I'm trying to figure out whether this is correct. With RDF 1.1 semantics "Test"
is interpreted as an xsd:string
. It's an rdf:PlainLiteral
in Protege because that's what it is in OWL. RDF 1.1 has rdf:langString
but the value space only contains non-empty lang tags, so there is a mismatch between rdf:PlainLiteral
and rdf:langString
. Thus, the translation to "Test"^^xsd:string
(to be explicit) seems to be correct here.
@matthewhorridge Thank you very much, I have tested the query in the new beta and it works. However, I have noticed that when I explicitly declare the datatype as xsd:string
or rdf:PlainLiteral
in the query, I still get zero results.
Hi @Daniele,
The behaviour with rdf:PlainLiteral
makes sense. A string without a language tag can be an rdf:PlainLiteral in OWL, but there is no equivalent in SPARQL 1.1. It must either be an xsd:string or an rdf:langString with a non-empty language tag. On this note, I'll have to look into why an explicit xsd:string type doesn't work in this case. This is all under RDF semantics, with OWL entailment "Test"^^rdf:PlainLiteral
and "Test"^^xsd:string
are equivalent.
This simple query is not working in the SPARQL Query tab of Protégé version 5.5.0 beta 3 (and also in version 5.2):
The ontology contains a single individual with rdfs:label "Test". If I specify the datatype it works correctly.