Dear all,

I have a problem with inference value. I create two rdf files. One for
schema, one for data
For schema rdf file, I create subclass a2 of a1, and one dataproperty p1.
a2 have definition "a1 and p1 some float[>2]"

I expect some instant when I query for a2 but Jena returns nothing. I
attach rdf files and my code below. Could anyone help me to solve problem.

Thank in advance.
Binh



*(1) for schema*

<?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 rdfs "http://www.w3.org/2000/01/rdf-schema#"; >
    <!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#"; >
    <!ENTITY Ontology1322586150669 "
http://www.semanticweb.org/ontologies/2011/10/Ontology1322586150669.owl#"; >
]>
<rdf:RDF xmlns="
http://www.semanticweb.org/ontologies/2011/10/Ontology1322586150669.owl#";
     xml:base="
http://www.semanticweb.org/ontologies/2011/10/Ontology1322586150669.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:Ontology1322586150669="
http://www.semanticweb.org/ontologies/2011/10/Ontology1322586150669.owl#";>
    <owl:Ontology rdf:about="
http://www.semanticweb.org/ontologies/2011/10/Ontology1322586150669.owl"/>
    <!--

///////////////////////////////////////////////////////////////////////////////////////
    //
    // Datatypes
    //

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

///////////////////////////////////////////////////////////////////////////////////////
    //
    // Data properties
    //

///////////////////////////////////////////////////////////////////////////////////////
     -->
    <!--
http://www.semanticweb.org/ontologies/2011/10/Ontology1322586150669.owl#p1-->
    <owl:DatatypeProperty rdf:about="&Ontology1322586150669;p1"/>
    <!--

///////////////////////////////////////////////////////////////////////////////////////
    //
    // Classes
    //

///////////////////////////////////////////////////////////////////////////////////////
     -->
    <!--
http://www.semanticweb.org/ontologies/2011/10/Ontology1322586150669.owl#a1-->
    <owl:Class rdf:about="&Ontology1322586150669;a1"/>
    <!--
http://www.semanticweb.org/ontologies/2011/10/Ontology1322586150669.owl#a2-->
    <owl:Class rdf:about="&Ontology1322586150669;a2">
        <rdfs:subClassOf>
            <owl:Class>
                <owl:intersectionOf rdf:parseType="Collection">
                    <rdf:Description rdf:about="&Ontology1322586150669;a1"/>
                    <owl:Restriction>
                        <owl:onProperty
rdf:resource="&Ontology1322586150669;p1"/>
                        <owl:someValuesFrom>
                            <rdfs:Datatype>
                                <owl:onDatatype rdf:resource="&xsd;float"/>
                                <owl:withRestrictions
rdf:parseType="Collection">
                                    <rdf:Description>
                                        <xsd:minExclusive
rdf:datatype="&xsd;integer">2</xsd:minExclusive>
                                    </rdf:Description>
                                </owl:withRestrictions>
                            </rdfs:Datatype>
                        </owl:someValuesFrom>
                    </owl:Restriction>
                </owl:intersectionOf>
            </owl:Class>
        </rdfs:subClassOf>
    </owl:Class>
</rdf:RDF>
<!-- Generated by the OWL API (version 3.2.3.22702)
http://owlapi.sourceforge.net -->

*(2) for data*
<?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 rdfs "http://www.w3.org/2000/01/rdf-schema#"; >
    <!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#"; >
    <!ENTITY Ontology1322586150669 "
http://www.semanticweb.org/ontologies/2011/10/Ontology1322586150669.owl#"; >
]>
<rdf:RDF xmlns="
http://www.semanticweb.org/ontologies/2011/10/Ontology1322586466073.owl#";
     xml:base="
http://www.semanticweb.org/ontologies/2011/10/Ontology1322586466073.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:Ontology1322586150669="
http://www.semanticweb.org/ontologies/2011/10/Ontology1322586150669.owl#";>
    <owl:Ontology rdf:about="
http://www.semanticweb.org/ontologies/2011/10/Ontology1322586466073.owl"/>
    <!--

///////////////////////////////////////////////////////////////////////////////////////
    //
    // Datatypes
    //

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

///////////////////////////////////////////////////////////////////////////////////////
    //
    // Data properties
    //

///////////////////////////////////////////////////////////////////////////////////////
     -->
    <!--
http://www.semanticweb.org/ontologies/2011/10/Ontology1322586150669.owl#p1-->
    <owl:DatatypeProperty rdf:about="&Ontology1322586150669;p1"/>
    <!--

///////////////////////////////////////////////////////////////////////////////////////
    //
    // Classes
    //

///////////////////////////////////////////////////////////////////////////////////////
     -->
    <!--
http://www.semanticweb.org/ontologies/2011/10/Ontology1322586150669.owl#a1-->
    <owl:Class rdf:about="&Ontology1322586150669;a1"/>
    <!--

///////////////////////////////////////////////////////////////////////////////////////
    //
    // Individuals
    //

///////////////////////////////////////////////////////////////////////////////////////
     -->
    <!--
http://www.semanticweb.org/ontologies/2011/10/Ontology1322586150669.owl#c-->

    <owl:NamedIndividual rdf:about="&Ontology1322586150669;c">
        <rdf:type rdf:resource="&Ontology1322586150669;a1"/>
        <Ontology1322586150669:p1
rdf:datatype="&xsd;float">5</Ontology1322586150669:p1>
    </owl:NamedIndividual>
    <owl:NamedIndividual rdf:about="&Ontology1322586150669;q">
        <rdf:type rdf:resource="&Ontology1322586150669;a1"/>
        <Ontology1322586150669:p1
rdf:datatype="&xsd;float">1</Ontology1322586150669:p1>
    </owl:NamedIndividual>
    <!--
http://www.semanticweb.org/ontologies/2011/10/Ontology1322586150669.owl#rf-->
    <owl:NamedIndividual rdf:about="&Ontology1322586150669;rf">
        <rdf:type rdf:resource="&Ontology1322586150669;a1"/>
        <Ontology1322586150669:p1
rdf:datatype="&xsd;float">16</Ontology1322586150669:p1>
    </owl:NamedIndividual>
</rdf:RDF>
<!-- Generated by the OWL API (version 3.2.3.22702)
http://owlapi.sourceforge.net -->


*This is my code in Jena*

package query;
    import com.hp.hpl.jena.query.*;
    import com.hp.hpl.jena.rdf.model.*;
    import com.hp.hpl.jena.reasoner.*;
    import com.hp.hpl.jena.util.FileManager;

public class query {

    public static void main(String[] args) {

        Model schema = FileManager.get().loadModel("O1.owl");
        Model data = FileManager.get().loadModel("O2.owl");

        Reasoner reasoner = ReasonerRegistry.getOWLReasoner();
        reasoner = reasoner.bindSchema(schema);
        InfModel infmodel = ModelFactory.createInfModel(reasoner, data);

        String queryString =
            "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>"+
            "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>"+
            "PREFIX test: <
http://www.semanticweb.org/ontologies/2011/10/Ontology1322586150669.owl#>"+
            "select ?data " +
            "where {?data a test:a2}";

            Query query = QueryFactory.create(queryString);

            System.out.println("----------------------");
            System.out.println("Query Result Sheet");
            System.out.println("----------------------");
            System.out.println("Direct&Indirect Descendants (inf)");
            System.out.println("-------------------");

            // Execute the query and obtain results
            QueryExecution qe = QueryExecutionFactory.create(query,
infmodel);
            ResultSet results = qe.execSelect();

            // Output query results
            ResultSetFormatter.out(System.out, results, query);

            qe.close();
            System.out.println("----------------------");


    }
}



-- 
Trần Thái Bình
GIS and Remote Sensing
thaibinht...@gmail.com
ttb...@vast-hcm.ac.vn
Phone: (848) 38247360
mobile:
- Việt Nam -
------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure 
contains a definitive record of customers, application performance, 
security threats, fraudulent activity, and more. Splunk takes this 
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
_______________________________________________
d2rq-map-devel mailing list
d2rq-map-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/d2rq-map-devel

Reply via email to