How to get data and properties of an object of class OWL using SPARQL?

I have a complex OWL ontology with many classes. Which SPARQL query do I need to use to retrieve the data and properties of an object of one OWL class (for example, the Person class)?

+2
source share
2 answers

In addition to the Jukka Matilainen answer , there are a few points to consider. OWL is not an object-oriented programming language, and the concept of classes and properties does not coincide with classes and properties in object-oriented programming languages. When we claim that

p rdfs:domain C

, , p . , ,

x p something

, x C. , , , p C , , x p something, , x C. :

 x p _     p rdfs:domain C
 ------------------------- [1]
       x rdf:type C

rdfs:subClassOf. , , C rdfs:subClassOf D , , C, , D. :

x rdf:type C    C rdfs:subClassOf D
----------------------------------- [2]
        x rdf:type D

? , , p C, C D, , D () p. ? , x p _, p rdfs:domain C, C rdfs:subClassOf D. , [1] , x rdf:type C. , C D, x rdf:type D. x , x p _ x rdf:type D, p rdfs:domain D.

, foaf:Person , OWL, SPARQL, . , foaf:Person, .

SPARQL, , , values

{ ?property a owl:DatatypeProperty } UNION { ?property a owl:ObjectProperty }

, ?property rdf:type, :

PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX owl:  <http://www.w3.org/2002/07/owl#>

SELECT ?property
FROM <http://xmlns.com/foaf/spec/index.rdf>
WHERE {
  values ?propertyType { owl:DatatypeProperty owl:ObjectProperty }
  ?property a ?propertyType ;
            rdfs:domain foaf:Person .
}

, , foaf:Person, OWL SPARQL, :

PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX owl:  <http://www.w3.org/2002/07/owl#>

SELECT ?property
FROM <http://xmlns.com/foaf/spec/index.rdf>
WHERE {
  values ?propertyType { owl:DatatypeProperty owl:ObjectProperty }
  ?property a ?propertyType ;
            rdfs:domain/rdfs:subClassOf* foaf:Person .
}
+7

OWL (, FOAF), , ( foaf: Person), , SPARQL, :

PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX owl:  <http://www.w3.org/2002/07/owl#>

SELECT ?property
FROM <http://xmlns.com/foaf/spec/index.rdf>
WHERE {
  { ?property a owl:DatatypeProperty } UNION { ?property a owl:ObjectProperty }
  ?property rdfs:domain foaf:Person 
}
+2

Source: https://habr.com/ru/post/1525650/


All Articles