In the following example the classes enter code here :Class3 and :Class4 are inferred by OWL reasoner (e.g. Pellet) as types of the individual :Ind1:
@prefix : <http://www.semanticweb.org/test/2015/1/ontology#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix xml: <http://www.w3.org/XML/1998/namespace> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@base <http://www.semanticweb.org/test/2015/1/ontology> .
<http://www.semanticweb.org/test/2015/1/ontology> rdf:type owl:Ontology .
:Prop1 rdf:type owl:DatatypeProperty .
:Prop2 rdf:type owl:DatatypeProperty .
:Prop3 rdf:type owl:DatatypeProperty .
:Class1 rdf:type owl:Class ;
owl:equivalentClass [ rdf:type owl:Restriction ;
owl:onProperty :Prop1 ;
owl:someValuesFrom xsd:string
] .
:Class2 rdf:type owl:Class ;
owl:equivalentClass [ rdf:type owl:Restriction ;
owl:onProperty :Prop2 ;
owl:someValuesFrom xsd:string
] .
:Class3 rdf:type owl:Class ;
owl:equivalentClass [ rdf:type owl:Restriction ;
owl:onProperty :Prop3 ;
owl:someValuesFrom xsd:string
] .
:Class4 rdf:type owl:Class ;
owl:equivalentClass [ rdf:type owl:Class ;
owl:intersectionOf ( :Class1
:Class2
)
] .
:Class5 rdf:type owl:Class ;
owl:equivalentClass [ rdf:type owl:Class ;
owl:unionOf ( :Class3
:Class4
)
] .
:Ind1 rdf:type owl:NamedIndividual ;
:Prop2 "prop2" ;
:Prop1 "prop1" ;
:Prop3 "prop3" .
The :Class4 e.g. is inferred by reasoner based on properties :Prop1 and :Prop2 of the :Ind1.
I need to construct an individual of type :Class4 from the :Ind1, something like this:
:Ind_Class4 rdf:type :Class4
:Ind_Class4 :Prop1 "Prop1"
:Ind_Class4 :Prop2 "Prop2"
I'm looking how to select the properties :Prop1 and :Prop2 of the :Ind1 as the properties of the class :Class4.
I've tried the SPARQL query
select * where {
?s rdf:type :Class4 .
?s ?p ?o .
}
but it returns all properties of :Ind1 - :Prop1, :Prop2 and :Prop3:
:Ind1 :Prop1 "Prop1"
:Ind1 :Prop2 "Prop2"
:Ind1 :Prop3 "Prop3"
If I change ontology as suggested in Answer1:
:Prop1 rdf:type owl:DatatypeProperty ;
rdfs:domain :Class1 .
:Prop2 rdf:type owl:DatatypeProperty ;
rdfs:domain :Class2 .
:Prop3 rdf:type owl:DatatypeProperty ;
rdfs:domain :Class3 .
:Class1 rdf:type owl:Class .
:Class2 rdf:type owl:Class .
:Class3 rdf:type owl:Class .
:Class4 rdf:type owl:Class ;
owl:equivalentClass [ rdf:type owl:Class ;
owl:intersectionOf ( :Class1
:Class2
)
] .
:Class5 rdf:type owl:Class ;
owl:equivalentClass [ rdf:type owl:Class ;
owl:unionOf ( :Class3
:Class4
)
] .
:Ind1 rdf:type owl:NamedIndividual ;
:Prop1 "Prop1" ;
:Prop3 "Prop3" ;
:Prop2 "Prop2" .
then the suggested SPARQL query
select * where {
?p rdfs:domain :Class4 .
?s ?p ?o .
}
returns an empty resultset.
Thanks.