You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Fábio Coradini <fa...@gmail.com> on 2012/12/13 12:43:15 UTC

SPARQL query problem

Hi,
I´m developing a Java + Jena application but I´m having a problem with a
SPARQL query.

I have a simple genealogy OWL ontology defined as follows:

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

///////////////////////////////////////////////////////////////////////////////////////
-->

    <!-- http://www.semanticweb.org/parentesco-simples.owl#isTheFatherOf
 -->

    <owl:ObjectProperty rdf:about="&parentesco-simples;isTheFatherOf"/>

    <!-- http://www.semanticweb.org/parentesco-simples.owl#isTheSonOf
 -->

    <owl:ObjectProperty rdf:about="&parentesco-simples;isTheSonOf">
        <owl:inverseOf rdf:resource="&parentesco-simples;isTheFatherOf"/>
    </owl:ObjectProperty>

    <!-- http://www.semanticweb.org/parentesco-simples.owl#outra
 -->

    <owl:ObjectProperty rdf:about="&parentesco-simples;outra"/>



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

///////////////////////////////////////////////////////////////////////////////////////
-->

    <!-- http://www.semanticweb.org/parentesco-simples.owl#Father
 -->

    <owl:Class rdf:about="&parentesco-simples;Father">
        <owl:equivalentClass>
            <owl:Restriction>
                <owl:onProperty
rdf:resource="&parentesco-simples;isTheFatherOf"/>
                <owl:someValuesFrom rdf:resource="&parentesco-simples;Son"/>
            </owl:Restriction>
        </owl:equivalentClass>
    </owl:Class>

    <!-- http://www.semanticweb.org/parentesco-simples.owl#Son
 -->

    <owl:Class rdf:about="&parentesco-simples;Son">
        <owl:equivalentClass>
            <owl:Restriction>
                <owl:onProperty
rdf:resource="&parentesco-simples;isTheSonOf"/>
                <owl:someValuesFrom
rdf:resource="&parentesco-simples;Father"/>
            </owl:Restriction>
        </owl:equivalentClass>
        <rdfs:subClassOf rdf:resource="&owl;Thing"/>
    </owl:Class>


I´m trying this query:

PREFIX owl: <http://www.w3.org/2002/07/owl#
>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#
>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#
>
PREFIX ns: <http://www.semanticweb.org/parentesco-simples.owl#
>

SELECT ?x ?y ?z
WHERE {
  ?x owl:onProperty ?y .
  ?x owl:someValuesFrom ?z .
}

And as results, I have:

------------------------------------------------------
|  x   |               y          |      z         |
============================
| _:b0 | ns:isTheSonOf    | ns:Father |
| _:b1 | ns:isTheFatherOf | ns:Son    |
-------------------------------------------------------

I´m in doubt about the blanknodes _:b0 and _:b0. They refer to which class?

I would like to have the following results:

-----------------------------------------------------------
|       x      |               y          |      z        |
============================
| ns:Son    | ns:isTheSonOf    | ns:Father |
| ns:Father | ns:isTheFatherOf | ns:Son   |
-------------------------------------------------------------

It is possible? Can somebody please help me to know how?

Thank you in advance!