Question

I am new to ontologies. I am creating an .owl file by using protege 4.3. I am accessing object properties by using SPARQL queries such as:

Prefix: <http://www.workingontologist.org/Examples/Chapter3/Product.owl#>

select ?x ?y where { 
  ?x :hasPizza ?y
}

This works fine, and shows all object properties related to the member.

When I access data properties from that owl file, I am not able to read or access data properties

Please give suggestions on how I can access data properties from that owl file

Thanks for helping

my owl file is

<?xml version="1.0"?>
<!DOCTYPE rdf:RDF [
    <!ENTITY owl "http://www.w3.org/2002/07/owl#" >
    <!ENTITY xsd "http://www.w3.org/2001/XMLSchema#" >
    <!ENTITY daml "http://www.daml.org/2001/03/daml+oil#" >
    <!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#" >
    <!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#" >
    <!ENTITY mfg "http://www.workingontologist.org/Examples/Chapter3/Product.owl#" >
]>
<rdf:RDF xmlns="http://www.workingontologist.org/Examples/Chapter3/Product.owl#"
     xml:base="http://www.workingontologist.org/Examples/Chapter3/Product.owl"
     xmlns:mfg="http://www.workingontologist.org/Examples/Chapter3/Product.owl#"
     xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
     xmlns:owl="http://www.w3.org/2002/07/owl#"
     xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
     xmlns:daml="http://www.daml.org/2001/03/daml+oil#">
    <owl:Ontology rdf:about="http://www.workingontologist.org/Examples/Chapter3/Product.owl">
        <owl:versionInfo rdf:datatype="&xsd;string">Created with TopBraid Spreadsheet converter</owl:versionInfo>
    </owl:Ontology>

    <!-- 
    ///////////////////////////////////////////////////////////////////////////////////////
    //
    // Object Properties
    //
    ///////////////////////////////////////////////////////////////////////////////////////
     -->




    <!-- http://www.workingontologist.org/Examples/Chapter3/Product.owl#hasPizza -->
    <owl:ObjectProperty rdf:about="&mfg;hasPizza"/>

    <!-- 
    ///////////////////////////////////////////////////////////////////////////////////////
    //
    // Data properties
    //
    ///////////////////////////////////////////////////////////////////////////////////////
     -->




    <!-- http://www.workingontologist.org/Examples/Chapter3/Product.owl#Product_Available -->

    <owl:DatatypeProperty rdf:about="&mfg;Product_Available">
        <rdfs:label rdf:datatype="&xsd;string">Available</rdfs:label>
        <rdfs:range rdf:resource="&xsd;string"/>
        <rdfs:domain rdf:resource="&mfg;Product"/>
    </owl:DatatypeProperty>



    <!-- http://www.workingontologist.org/Examples/Chapter3/Product.owl#Product_Division -->

    <owl:DatatypeProperty rdf:about="&mfg;Product_Division">
        <rdfs:label rdf:datatype="&xsd;string">Division</rdfs:label>
        <rdfs:range rdf:resource="&xsd;string"/>
        <rdfs:domain rdf:resource="&mfg;Product"/>
    </owl:DatatypeProperty>



    <!-- http://www.workingontologist.org/Examples/Chapter3/Product.owl#Product_ID -->

    <owl:DatatypeProperty rdf:about="&mfg;Product_ID">
        <rdfs:label rdf:datatype="&xsd;string">ID</rdfs:label>
        <rdfs:range rdf:resource="&xsd;string"/>
        <rdfs:domain rdf:resource="&mfg;Product"/>
    </owl:DatatypeProperty>



    <!-- http://www.workingontologist.org/Examples/Chapter3/Product.owl#Product_Manufacture_Location -->

    <owl:DatatypeProperty rdf:about="&mfg;Product_Manufacture_Location">
        <rdfs:label rdf:datatype="&xsd;string">Manufacture Location</rdfs:label>
        <rdfs:range rdf:resource="&xsd;string"/>
        <rdfs:domain rdf:resource="&mfg;Product"/>
    </owl:DatatypeProperty>



    <!-- http://www.workingontologist.org/Examples/Chapter3/Product.owl#Product_ModelNo -->

    <owl:DatatypeProperty rdf:about="&mfg;Product_ModelNo">
        <rdfs:label rdf:datatype="&xsd;string">ModelNo</rdfs:label>
        <rdfs:range rdf:resource="&xsd;string"/>
        <rdfs:domain rdf:resource="&mfg;Product"/>
    </owl:DatatypeProperty>



    <!-- http://www.workingontologist.org/Examples/Chapter3/Product.owl#Product_Product_Line -->

    <owl:DatatypeProperty rdf:about="&mfg;Product_Product_Line">
        <rdfs:label rdf:datatype="&xsd;string">Product Line</rdfs:label>
        <rdfs:range rdf:resource="&xsd;string"/>
        <rdfs:domain rdf:resource="&mfg;Product"/>
    </owl:DatatypeProperty>



    <!-- http://www.workingontologist.org/Examples/Chapter3/Product.owl#Product_SKU -->

    <owl:DatatypeProperty rdf:about="&mfg;Product_SKU">
        <rdfs:label rdf:datatype="&xsd;string">SKU</rdfs:label>
        <rdfs:range rdf:resource="&xsd;string"/>
        <rdfs:domain rdf:resource="&mfg;Product"/>
    </owl:DatatypeProperty>



    <!-- 
    ///////////////////////////////////////////////////////////////////////////////////////
    //
    // Classes
    //
    ///////////////////////////////////////////////////////////////////////////////////////
     -->




    <!-- http://www.workingontologist.org/Examples/Chapter3/Product.owl#Product -->

    <owl:Class rdf:about="&mfg;Product"/>



    <!-- 
    ///////////////////////////////////////////////////////////////////////////////////////
    //
    // Individuals
    //
    ///////////////////////////////////////////////////////////////////////////////////////
     -->




    <!-- http://www.workingontologist.org/Examples/Chapter3/Product.owl#Product1 -->

    <owl:NamedIndividual rdf:about="&mfg;Product1">
        <rdf:type rdf:resource="&mfg;Product"/>
        <rdfs:label rdf:datatype="&xsd;string">Product 1</rdfs:label>
        <Product_ID rdf:datatype="&xsd;string">1</Product_ID>
        <Product_Available rdf:datatype="&xsd;string">23</Product_Available>
        <Product_SKU rdf:datatype="&xsd;string">FB3524</Product_SKU>
        <Product_Division rdf:datatype="&xsd;string">Manufacturing support</Product_Division>
        <Product_Product_Line rdf:datatype="&xsd;string">Papermachine</Product_Product_Line>
        <Product_Manufacture_Location rdf:datatype="&xsd;string">Sacramento</Product_Manufacture_Location>
        <Product_ModelNo rdf:datatype="&xsd;string">ZX-3</Product_ModelNo>
        <hasPizza rdf:resource="&mfg;Product1"/>
        <hasPizza rdf:resource="&mfg;Product2"/>
        <hasPizza rdf:resource="&mfg;Product3"/>
    </owl:NamedIndividual>



    <!-- http://www.workingontologist.org/Examples/Chapter3/Product.owl#Product2 -->

    <owl:NamedIndividual rdf:about="&mfg;Product2">
        <rdf:type rdf:resource="&mfg;Product"/>
        <rdfs:label rdf:datatype="&xsd;string">Product 2</rdfs:label>
        <Product_ID rdf:datatype="&xsd;string">2</Product_ID>
        <Product_Available rdf:datatype="&xsd;string">4</Product_Available>
        <Product_SKU rdf:datatype="&xsd;string">KD5243</Product_SKU>
        <Product_Division rdf:datatype="&xsd;string">Manufacturing support</Product_Division>
        <Product_Product_Line rdf:datatype="&xsd;string">Paper machine</Product_Product_Line>
        <Product_Manufacture_Location rdf:datatype="&xsd;string">Sacramento</Product_Manufacture_Location>
        <Product_ModelNo rdf:datatype="&xsd;string">ZX-3P</Product_ModelNo>
        <hasPizza rdf:resource="&mfg;Product2"/>
        <hasPizza rdf:resource="&mfg;Product7"/>
    </owl:NamedIndividual>



    <!-- http://www.workingontologist.org/Examples/Chapter3/Product.owl#Product3 -->

    <owl:NamedIndividual rdf:about="&mfg;Product3">
        <rdf:type rdf:resource="&mfg;Product"/>
        <rdfs:label rdf:datatype="&xsd;string">Product 3</rdfs:label>
        <Product_ID rdf:datatype="&xsd;string">3</Product_ID>
        <Product_Available rdf:datatype="&xsd;string">34</Product_Available>
        <Product_SKU rdf:datatype="&xsd;string">IL4028</Product_SKU>
        <Product_Division rdf:datatype="&xsd;string">Manufacturing support</Product_Division>
        <Product_Product_Line rdf:datatype="&xsd;string">Paper machine</Product_Product_Line>
        <Product_Manufacture_Location rdf:datatype="&xsd;string">Sacramento</Product_Manufacture_Location>
        <Product_ModelNo rdf:datatype="&xsd;string">ZX-3S</Product_ModelNo>
    </owl:NamedIndividual>



    <!-- http://www.workingontologist.org/Examples/Chapter3/Product.owl#Product4 -->

    <owl:NamedIndividual rdf:about="&mfg;Product4">
        <rdf:type rdf:resource="&mfg;Product"/>
        <rdfs:label rdf:datatype="&xsd;string">Product 4</rdfs:label>
        <Product_Available rdf:datatype="&xsd;string">23</Product_Available>
        <Product_ID rdf:datatype="&xsd;string">4</Product_ID>
        <Product_ModelNo rdf:datatype="&xsd;string">B-1430</Product_ModelNo>
        <Product_Division rdf:datatype="&xsd;string">Control Engineering</Product_Division>
        <Product_Manufacture_Location rdf:datatype="&xsd;string">Elizabeth</Product_Manufacture_Location>
        <Product_Product_Line rdf:datatype="&xsd;string">Feedback line</Product_Product_Line>
        <Product_SKU rdf:datatype="&xsd;string">KS4520</Product_SKU>
    </owl:NamedIndividual>



    <!-- http://www.workingontologist.org/Examples/Chapter3/Product.owl#Product5 -->

    <owl:NamedIndividual rdf:about="&mfg;Product5">
        <rdf:type rdf:resource="&mfg;Product"/>
        <rdfs:label rdf:datatype="&xsd;string">Product 5</rdfs:label>
        <Product_Available rdf:datatype="&xsd;string">14</Product_Available>
        <Product_ID rdf:datatype="&xsd;string">5</Product_ID>
        <Product_ModelNo rdf:datatype="&xsd;string">B-1430X</Product_ModelNo>
        <Product_SKU rdf:datatype="&xsd;string">CL5934</Product_SKU>
        <Product_Division rdf:datatype="&xsd;string">Control Engineering</Product_Division>
        <Product_Manufacture_Location rdf:datatype="&xsd;string">Elizabeth</Product_Manufacture_Location>
        <Product_Product_Line rdf:datatype="&xsd;string">Feedback line</Product_Product_Line>
    </owl:NamedIndividual>



    <!-- http://www.workingontologist.org/Examples/Chapter3/Product.owl#Product6 -->

    <owl:NamedIndividual rdf:about="&mfg;Product6">
        <rdf:type rdf:resource="&mfg;Product"/>
        <rdfs:label rdf:datatype="&xsd;string">Product 6</rdfs:label>
        <Product_Available rdf:datatype="&xsd;string">0</Product_Available>
        <Product_ID rdf:datatype="&xsd;string">6</Product_ID>
        <Product_Product_Line rdf:datatype="&xsd;string">Active sensor</Product_Product_Line>
        <Product_ModelNo rdf:datatype="&xsd;string">B-1431</Product_ModelNo>
        <Product_Division rdf:datatype="&xsd;string">Control Engineering</Product_Division>
        <Product_SKU rdf:datatype="&xsd;string">KK3945</Product_SKU>
        <Product_Manufacture_Location rdf:datatype="&xsd;string">Seoul</Product_Manufacture_Location>
    </owl:NamedIndividual>



    <!-- http://www.workingontologist.org/Examples/Chapter3/Product.owl#Product7 -->

    <owl:NamedIndividual rdf:about="&mfg;Product7">
        <rdf:type rdf:resource="&mfg;Product"/>
        <rdfs:label rdf:datatype="&xsd;string">Product 7</rdfs:label>
        <Product_Available rdf:datatype="&xsd;string">100</Product_Available>
        <Product_ID rdf:datatype="&xsd;string">7</Product_ID>
        <Product_Division rdf:datatype="&xsd;string">Accessories</Product_Division>
        <Product_ModelNo rdf:datatype="&xsd;string">DBB-12</Product_ModelNo>
        <Product_Manufacture_Location rdf:datatype="&xsd;string">Hong Kong</Product_Manufacture_Location>
        <Product_Product_Line rdf:datatype="&xsd;string">Monitor</Product_Product_Line>
        <Product_SKU rdf:datatype="&xsd;string">ND5520</Product_SKU>
    </owl:NamedIndividual>



    <!-- http://www.workingontologist.org/Examples/Chapter3/Product.owl#Product8 -->

    <owl:NamedIndividual rdf:about="&mfg;Product8">
        <rdf:type rdf:resource="&mfg;Product"/>
        <rdfs:label rdf:datatype="&xsd;string">Product 8</rdfs:label>
        <Product_ID rdf:datatype="&xsd;string">8</Product_ID>
        <Product_SKU rdf:datatype="&xsd;string">Cleveland</Product_SKU>
        <Product_Available rdf:datatype="&xsd;string">HI4554</Product_Available>
        <Product_ModelNo rdf:datatype="&xsd;string">SP-1234</Product_ModelNo>
        <Product_Division rdf:datatype="&xsd;string">Safety</Product_Division>
        <Product_Product_Line rdf:datatype="&xsd;string">Safety</Product_Product_Line>
        <Product_Manufacture_Location rdf:datatype="&xsd;string">valve</Product_Manufacture_Location>
    </owl:NamedIndividual>



    <!-- http://www.workingontologist.org/Examples/Chapter3/Product.owl#Product9 -->

    <owl:NamedIndividual rdf:about="&mfg;Product9">
        <rdf:type rdf:resource="&mfg;Product"/>
        <rdfs:label rdf:datatype="&xsd;string">Product 9</rdfs:label>
        <Product_ID rdf:datatype="&xsd;string">9</Product_ID>
        <Product_SKU rdf:datatype="&xsd;string">Cleveland</Product_SKU>
        <Product_Available rdf:datatype="&xsd;string">OP5333</Product_Available>
        <Product_ModelNo rdf:datatype="&xsd;string">SPX-1234</Product_ModelNo>
        <Product_Product_Line rdf:datatype="&xsd;string">Safety</Product_Product_Line>
        <Product_Division rdf:datatype="&xsd;string">Safety</Product_Division>
        <Product_Manufacture_Location rdf:datatype="&xsd;string">valve</Product_Manufacture_Location>
    </owl:NamedIndividual>
    <rdf:Description>
        <Product_ID></Product_ID>
    </rdf:Description>
</rdf:RDF>
Was it helpful?

Solution

In your data, there's a datatype property with the IRI http://www.workingontologist.org/Examples/Chapter3/Product.owl#Product_SKU. You can retrieve subjects and objects of that predicate with a SPARQL query like this:

prefix mfg:   <http://www.workingontologist.org/Examples/Chapter3/Product.owl#>

select ?x ?y where {
  ?x mfg:Product_SKU ?y
}
-------------------------------------------------------------------------
| x            | y                                                      |
=========================================================================
| mfg:Product9 | "Cleveland"^^<http://www.w3.org/2001/XMLSchema#string> |
| mfg:Product8 | "Cleveland"^^<http://www.w3.org/2001/XMLSchema#string> |
| mfg:Product7 | "ND5520"^^<http://www.w3.org/2001/XMLSchema#string>    |
| mfg:Product6 | "KK3945"^^<http://www.w3.org/2001/XMLSchema#string>    |
| mfg:Product5 | "CL5934"^^<http://www.w3.org/2001/XMLSchema#string>    |
| mfg:Product4 | "KS4520"^^<http://www.w3.org/2001/XMLSchema#string>    |
| mfg:Product3 | "IL4028"^^<http://www.w3.org/2001/XMLSchema#string>    |
| mfg:Product2 | "KD5243"^^<http://www.w3.org/2001/XMLSchema#string>    |
| mfg:Product1 | "FB3524"^^<http://www.w3.org/2001/XMLSchema#string>    |
-------------------------------------------------------------------------

OTHER TIPS

The question seems to be about datatype vs. object properties. In SPARQL, no real distinction is made in terms of how these properties are used, as both datatype and object properties are URIs that can be specified in exactly the same way in a query. The only difference is that the object of the triple pattern will be a literal for datatype properties.

If you need to find all of the datatype properties in the ontology, use the following:

SELECT ?p
WHERE {
   ?p a owl:DatatypeProperty
}

Then use the values of ?p to query for the data.

Or, alternatively, you can find all literals in the ontology using:

SELECT *
WHERE {
   ?s ?p ?o
   FILTER (isLiteral(?o))
}

This is a computationally expensive query, so you may want to use it in combination with the first query to isolate the property, then check whether the values are literals. This can be useful for checking that the types for triples are correct (object vs. datatype). Also, properties of type rdf:Property allows either objects (URIs) or literals, and this query can find those that are literals.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top