Your terminology indicates that there might be some conceptual misunderstanding
SELECT * WHERE {?s a wel:Sentence1 }
Using the above code I can get all the individuals, object properties and data properties that belongs to class
wel:Sentence1
.
If you're working in OWL, and wel:Sentence
is an OWL class, then the only things that should be in triples of the form ?s a wel:Sentence1
are individuals. Only individuals belong to OWL classes; object properties and data properties don't belong to OWL classes, so there shouldn't be any object properties or data properties belonging to wel:Sentence1
to retrieve at all.
At any rate, a
is just shorthand for the property rdf:type
. It sounds like you're trying to retrieve individuals that have the string "SnowWhiteAndTheSevenDwarfs"
as the value of the property wel:belongs_to_story
, in which case you should be able to use the query
#-- ...prefixes...
select * where {
?s wel:belongs_to_story "SnowWhiteAndTheSevenDwarfs"
}
However, your data actually looks more like this (from the link that you provided):
<!-- http://www.semanticweb.org/dell/ontologies/2014/2/untitled-ontology-11#SnowWhite -->
<NamedIndividual rdf:about="&untitled-ontology-11;SnowWhite">
<rdf:type rdf:resource="&untitled-ontology-11;Heroien"/>
<!-- … -->
<untitled-ontology-11:belongs_to_story rdf:resource="&untitled-ontology-11;SnowWhiteAndTheSevenDwarfs"/>
<!-- … -->
</NamedIndividual>
The value of the belongs_to_story
property isn't a string; it's another resource, identified by an IRI that would be abbreviated as SnowWhiteAndTheSevenDwarfs
. This is actually a bit clearer if you use the more human readable Turtle serialization, where your data would then be:
wel:SnowWhite a wel:Heroien , owl:NamedIndividual ;
# …
wel:belongs_to_story wel:SnowWhiteAndTheSevenDwarfs ;
# …
wel:saw wel:beds , wel:cups , wel:cottage , wel:chairs ;
wel:sleptOn wel:bed ;
wel:wentIn wel:cottage .
The Turtle serialization is actually very similar to the SPARQL syntax. Your query needs to be the following (with results generated by Jena's command line tools):
prefix wel: <http://www.semanticweb.org/dell/ontologies/2014/2/untitled-ontology-11#>
select * where {
?s wel:belongs_to_story wel:SnowWhiteAndTheSevenDwarfs
}
------------------
| s |
==================
| _:b0 |
| wel:castle |
| _:b1 |
| wel:SnowWhite |
| wel:StepMother |
------------------
The blank nodes (indicated by _:b0
and _:b1
are the axioms that you've annotated:
[ a owl:Axiom ;
wel:belongs_to_story
wel:SnowWhiteAndTheSevenDwarfs ;
wel:seq wel:Sentence1 ;
owl:annotatedProperty wel:livedIn ;
owl:annotatedSource wel:SnowWhite ;
owl:annotatedTarget wel:castle
] .
[ a owl:Axiom ;
wel:belongs_to_story
wel:SnowWhiteAndTheSevenDwarfs ;
wel:seq wel:Sentence2 ;
owl:annotatedProperty wel:livedWith ;
owl:annotatedSource wel:SnowWhite ;
owl:annotatedTarget wel:StepMother
] .