MaxCalzone
MaxCalzone

Reputation: 3

SPARQL: How to get a list of owl:onProperty on a selected class

how can i get a list of all the properties for a selected class? Example:

<!-- http://www.xxx.xx/ontologies/abcd.owl#selected -->

<owl:Class rdf:about="&selected;Selected">
    <owl:equivalentClass>
        <owl:Restriction>
            <owl:onProperty rdf:resource="&selected;a_xxyy"/>
            <owl:allValuesFrom rdf:resource="&selected;aaaaa"/>
        </owl:Restriction>
    </owl:equivalentClass>
    <owl:equivalentClass>
        <owl:Restriction>
            <owl:onProperty rdf:resource="&selected;a_yyzz"/>
            <owl:allValuesFrom rdf:resource="&selected;bbbb"/>
        </owl:Restriction>
    </owl:equivalentClass>
    <owl:equivalentClass>
        <owl:Restriction>
            <owl:onProperty rdf:resource="&selected;a_gggrrr"/>
            <owl:allValuesFrom>
                <rdfs:Datatype>
                    <owl:onDatatype rdf:resource="&xsd;integer"/>
                    <owl:withRestrictions rdf:parseType="Collection">
                        <rdf:Description>
                            <xsd:minInclusive rdf:datatype="&xsd;integer">18</xsd:minInclusive>
                        </rdf:Description>
                    </owl:withRestrictions>
                </rdfs:Datatype>
            </owl:allValuesFrom>
        </owl:Restriction>
    </owl:equivalentClass>

I wanna all the properties (and even the value) for the class <http://www.xxx.xx/ontologies/abcd.owl#selected>, like

|property|value|
|a_xxyy  |aaaaa|
|a_yyzz  |bbbb |
|a_gggrrr|<18  |

Upvotes: 0

Views: 1458

Answers (1)

Joshua Taylor
Joshua Taylor

Reputation: 85913

all the properties for a selected class

The RDF serialization you're showing is a bunch of equivalent class axioms where one of the classes is an anonymous restriction class. E.g.,

<owl:Class rdf:about="&selected;Selected">
    <owl:equivalentClass>
        <owl:Restriction>
            <owl:onProperty rdf:resource="&selected;a_xxyy"/>
            <owl:allValuesFrom rdf:resource="&selected;aaaaa"/>
        </owl:Restriction>
    </owl:equivalentClass>

says that

Selected ≡ ∀a_xxyy.aaaaa

which means that every value an instance of Selected has for the property a_xxyy must be an aaaaa. That doesn't really mean that a_xxyy is "a property for the class", though. After, a similarly structured axiom is

Human ⊑ ∀hasExoskeleton.Nothing

which says that no human has an exoskeleton. Thus hasExoskeleton wouldn't be considered "a property for Human". The form of the axiom is the same, though.

At any rate, the SPARQL query isn't very complicated. It would just be:

prefix owl:  <http://www.w3.org/2002/07/owl#>

select ?class ?property where {
  ?class owl:equivalentClass/owl:onProperty ?property
}

In reality, you'd probably want not just owl:equivalentClasses, but rdfs:subClasses too, so you could do:

prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix owl:  <http://www.w3.org/2002/07/owl#>

select ?class ?property where {
  ?class (rdfs:subClassOf|owl:equivalentClass)/owl:onProperty ?property
}

Upvotes: 1

Related Questions