0

我正在编写一个语义 Web 应用程序,但 Jena 遇到了一些问题。我想执行一个参数化查询并且没有结果。

以下代码显示了我的查询:

public ArrayList getPieceByContrName(String n){
    Property pr= infModel.getProperty(namespace+"NomPiecePreparer");
    ArrayList ef=new ArrayList();
    Query query = null;
    QueryExecution qe = null;
    String sql= "PREFIX supply: <http://www.semanticweb.org/ontologies/2012//Ontology1334514742253.owl#>"+
              " SELECT ?y " +
              " WHERE {" +
              " ?x supply:NomSControle \""+n+"\"." +
              "?x supply:controle ?y"+"." +
                         " }";

    com.hp.hpl.jena.query.ResultSet results = null;
    try{
    query=QueryFactory.create(sql);
     qe= QueryExecutionFactory.create(query,infModel);
     results =  qe.execSelect();
     System.out.println("rrrrr");

   } catch (Exception e) {
        e.printStackTrace();
   }
 while(results.hasNext()){
     System.out.println("hhhhh");
PiecePrepare pp = new PiecePrepare();
           QuerySolution soln = results.next() ;
         Resource r=  soln.get("y").asResource();
         System.out.println(r.getProperty(pr).getString());


 }

    qe.close();

}

这是我本体的一部分:

    <!-- http://www.semanticweb.org/ontologies/2012/3/Ontology1334514742253.owl#controle -->

    <owl:ObjectProperty rdf:about="&Ontology1334514742253;controle">
        <rdf:type rdf:resource="&owl;FunctionalProperty"/>
        <rdfs:domain rdf:resource="&Ontology1334514742253;EntiteControle"/>
        <rdfs:range rdf:resource="&Ontology1334514742253;PiecePrepare"/>
        <owl:inverseOf rdf:resource="&Ontology1334514742253;estControlee"/>
    </owl:ObjectProperty>



    <!-- http://www.semanticweb.org/ontologies/2012/3/Ontology1334514742253.owl#distribue -->

    <owl:ObjectProperty rdf:about="&Ontology1334514742253;distribue">
        <rdf:type rdf:resource="&owl;FunctionalProperty"/>
        <rdfs:domain rdf:resource="&Ontology1334514742253;EntiteDistributeur"/>
        <rdfs:range rdf:resource="&Ontology1334514742253;EntiteMarketing"/>
    </owl:ObjectProperty>



    <!-- http://www.semanticweb.org/ontologies/2012/3/Ontology1334514742253.owl#estControlee -->

    <owl:ObjectProperty rdf:about="&Ontology1334514742253;estControlee">
        <rdfs:domain rdf:resource="&Ontology1334514742253;EntiteAssemblage"/>
        <rdfs:range rdf:resource="&Ontology1334514742253;EntiteControle"/>
    </owl:ObjectProperty>
















    <!-- http://www.semanticweb.org/ontologies/2012/3/Ontology1334514742253.owl#NomPieceControle -->

    <owl:DatatypeProperty rdf:about="&Ontology1334514742253;NomPieceControle"/>



    <!-- http://www.semanticweb.org/ontologies/2012/3/Ontology1334514742253.owl#NomPiecePreparer -->

    <owl:DatatypeProperty rdf:about="&Ontology1334514742253;NomPiecePreparer"/>



    <!-- http://www.semanticweb.org/ontologies/2012/3/Ontology1334514742253.owl#NomSControle -->

    <owl:DatatypeProperty rdf:about="&Ontology1334514742253;NomSControle"/>



    <!-- http://www.semanticweb.org/ontologies/2012/3/Ontology1334514742253.owl#NombrePieceControle -->

    <owl:DatatypeProperty rdf:about="&Ontology1334514742253;NombrePieceControle"/>



    <!-- http://www.semanticweb.org/ontologies/2012/3/Ontology1334514742253.owl#NombreProd -->

    <owl:DatatypeProperty rdf:about="&Ontology1334514742253;NombreProd"/>



    <!-- http://www.semanticweb.org/ontologies/2012/3/Ontology1334514742253.owl#NombredePiecePrepa -->

    <owl:DatatypeProperty rdf:about="&Ontology1334514742253;NombredePiecePrepa"/>



    <!-- http://www.semanticweb.org/ontologies/2012/3/Ontology1334514742253.owl#Nomprodfinal -->

    <owl:DatatypeProperty rdf:about="&Ontology1334514742253;Nomprodfinal"/>



    <!-- http://www.semanticweb.org/ontologies/2012/3/Ontology1334514742253.owl#Pays -->

    <owl:DatatypeProperty rdf:about="&Ontology1334514742253;Pays"/>



    <!-- http://www.semanticweb.org/ontologies/2012/3/Ontology1334514742253.owl#PaysAssemb -->

    <owl:DatatypeProperty rdf:about="&Ontology1334514742253;PaysAssemb"/>





    <!-- http://www.semanticweb.org/ontologies/2012/3/Ontology1334514742253.owl#Typematiere -->

    <owl:DatatypeProperty rdf:about="&Ontology1334514742253;Typematiere"/>



    <!-- http://www.semanticweb.org/ontologies/2012/3/Ontology1334514742253.owl#Ville -->

    <owl:DatatypeProperty rdf:about="&Ontology1334514742253;Ville"/>



    <!-- http://www.semanticweb.org/ontologies/2012/3/Ontology1334514742253.owl#VilleAssemb -->

    <owl:DatatypeProperty rdf:about="&Ontology1334514742253;VilleAssemb"/>



    <!-- http://www.semanticweb.org/ontologies/2012/3/Ontology1334514742253.owl#VilleControle -->

    <owl:DatatypeProperty rdf:about="&Ontology1334514742253;VilleControle"/>



    <!-- http://www.semanticweb.org/ontologies/2012/3/Ontology1334514742253.owl#VilleDistr -->

    <owl:DatatypeProperty rdf:about="&Ontology1334514742253;VilleDistr"/>



    <!-- http://www.semanticweb.org/ontologies/2012/3/Ontology1334514742253.owl#VilleFab -->

    <owl:DatatypeProperty rdf:about="&Ontology1334514742253;VilleFab"/>



    <!-- http://www.semanticweb.org/ontologies/2012/3/Ontology1334514742253.owl#VilleMarketing -->

    <owl:DatatypeProperty rdf:about="&Ontology1334514742253;VilleMarketing"/>



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




    <!-- http://www.semanticweb.org/ontologies/2012/3/Ontology1334514742253.owl#DistributeurProduitFinaux -->

    <owl:Class rdf:about="&Ontology1334514742253;DistributeurProduitFinaux">
        <owl:equivalentClass>
            <owl:Class>
                <owl:intersectionOf rdf:parseType="Collection">
                    <rdf:Description rdf:about="&Ontology1334514742253;EntiteDistributeur"/>
                    <owl:Restriction>
                        <owl:onProperty rdf:resource="&Ontology1334514742253;distribue"/>
                        <owl:someValuesFrom rdf:resource="&Ontology1334514742253;ProduitFinalCommercial"/>
                    </owl:Restriction>
                </owl:intersectionOf>
            </owl:Class>
        </owl:equivalentClass>
        <rdfs:subClassOf rdf:resource="&Ontology1334514742253;EntiteDistributeur"/>
    </owl:Class>



    <!-- http://www.semanticweb.org/ontologies/2012/3/Ontology1334514742253.owl#EntiteAssemblage -->

    <owl:Class rdf:about="&Ontology1334514742253;EntiteAssemblage">
        <rdfs:subClassOf>
            <owl:Restriction>
                <owl:onProperty rdf:resource="&Ontology1334514742253;NomAssemb"/>
                <owl:allValuesFrom rdf:resource="&rdfs;Literal"/>
            </owl:Restriction>
        </rdfs:subClassOf>
        <rdfs:subClassOf>
            <owl:Restriction>
                <owl:onProperty rdf:resource="&Ontology1334514742253;PaysAssemb"/>
                <owl:allValuesFrom rdf:resource="&rdfs;Literal"/>
            </owl:Restriction>
        </rdfs:subClassOf>
        <rdfs:subClassOf>
            <owl:Restriction>
                <owl:onProperty rdf:resource="&Ontology1334514742253;VilleAssemb"/>
                <owl:allValuesFrom rdf:resource="&rdfs;Literal"/>
            </owl:Restriction>
        </rdfs:subClassOf>
        <rdfs:subClassOf>
            <owl:Restriction>
                <owl:onProperty rdf:resource="&Ontology1334514742253;AdresseAssemb"/>
                <owl:allValuesFrom rdf:resource="&rdfs;Literal"/>
            </owl:Restriction>
        </rdfs:subClassOf>
        <rdfs:comment>cette phase définit l&#39;assemblage des pièces automobile pour fomer le produit final à savoir une automobile(voiture)</rdfs:comment>
    </owl:Class>



    <!-- http://www.semanticweb.org/ontologies/2012/3/Ontology1334514742253.owl#EntiteAssemblageControle -->

    <owl:Class rdf:about="&Ontology1334514742253;EntiteAssemblageControle">
        <owl:equivalentClass>
            <owl:Class>
                <owl:intersectionOf rdf:parseType="Collection">
                    <rdf:Description rdf:about="&Ontology1334514742253;EntiteControle"/>
                    <owl:Restriction>
                        <owl:onProperty rdf:resource="&Ontology1334514742253;controle"/>
                        <owl:someValuesFrom rdf:resource="&Ontology1334514742253;PiecePrepare"/>
                    </owl:Restriction>
                </owl:intersectionOf>
            </owl:Class>
        </owl:equivalentClass>
        <rdfs:subClassOf rdf:resource="&Ontology1334514742253;EntiteControle"/>
    </owl:Class>



    <!-- http://www.semanticweb.org/ontologies/2012/3/Ontology1334514742253.owl#EntiteAssemblagePiece -->

    <owl:Class rdf:about="&Ontology1334514742253;EntiteAssemblagePiece">
        <owl:equivalentClass>
            <owl:Class>
                <owl:intersectionOf rdf:parseType="Collection">
                    <rdf:Description rdf:about="&Ontology1334514742253;EntiteAssemblage"/>
                    <owl:Restriction>
                        <owl:onProperty rdf:resource="&Ontology1334514742253;assemble"/>
                        <owl:someValuesFrom rdf:resource="&Ontology1334514742253;PiecePrepare"/>
                    </owl:Restriction>
                </owl:intersectionOf>
            </owl:Class>
        </owl:equivalentClass>
        <rdfs:subClassOf rdf:resource="&Ontology1334514742253;EntiteAssemblage"/>
    </owl:Class>



    <!-- http://www.semanticweb.org/ontologies/2012/3/Ontology1334514742253.owl#EntiteControle -->

    <owl:Class rdf:about="&Ontology1334514742253;EntiteControle">
        <rdfs:subClassOf>
            <owl:Restriction>
                <owl:onProperty rdf:resource="&Ontology1334514742253;VilleControle"/>
                <owl:allValuesFrom rdf:resource="&rdfs;Literal"/>
            </owl:Restriction>
        </rdfs:subClassOf>
        <rdfs:subClassOf>
            <owl:Restriction>
                <owl:onProperty rdf:resource="&Ontology1334514742253;AdresseControle"/>
                <owl:allValuesFrom rdf:resource="&rdfs;Literal"/>
            </owl:Restriction>
        </rdfs:subClassOf>
        <rdfs:subClassOf>
            <owl:Restriction>
                <owl:onProperty rdf:resource="&Ontology1334514742253;NomSControle"/>
                <owl:allValuesFrom rdf:resource="&rdfs;Literal"/>
            </owl:Restriction>
        </rdfs:subClassOf>
        <rdfs:subClassOf>
            <owl:Restriction>
                <owl:onProperty rdf:resource="&Ontology1334514742253;PaysControle"/>
                <owl:allValuesFrom rdf:resource="&rdfs;Literal"/>
            </owl:Restriction>
        </rdfs:subClassOf>
    </owl:Class>



    <!-- http://www.semanticweb.org/ontologies/2012/3/Ontology1334514742253.owl#EntiteDistributeur -->

    <owl:Class rdf:about="&Ontology1334514742253;EntiteDistributeur">
        <rdfs:subClassOf>
            <owl:Restriction>
                <owl:onProperty rdf:resource="&Ontology1334514742253;AdresseDistr"/>
                <owl:allValuesFrom rdf:resource="&rdfs;Literal"/>
            </owl:Restriction>
        </rdfs:subClassOf>
        <rdfs:subClassOf>
            <owl:Restriction>
                <owl:onProperty rdf:resource="&Ontology1334514742253;NomDistr"/>
                <owl:allValuesFrom rdf:resource="&rdfs;Literal"/>
            </owl:Restriction>
        </rdfs:subClassOf>
        <rdfs:subClassOf>
            <owl:Restriction>
                <owl:onProperty rdf:resource="&Ontology1334514742253;PaysDistr"/>
                <owl:allValuesFrom rdf:resource="&rdfs;Literal"/>
            </owl:Restriction>
        </rdfs:subClassOf>
        <rdfs:subClassOf>
            <owl:Restriction>
                <owl:onProperty rdf:resource="&Ontology1334514742253;VilleDistr"/>
                <owl:allValuesFrom rdf:resource="&rdfs;Literal"/>
            </owl:Restriction>
        </rdfs:subClassOf>
    </owl:Class>



    <!-- http://www.semanticweb.org/ontologies/2012/3/Ontology1334514742253.owl#EntiteFabLiv -->

    <owl:Class rdf:about="&Ontology1334514742253;EntiteFabLiv">
        <owl:equivalentClass>
            <owl:Class>
                <owl:intersectionOf rdf:parseType="Collection">
                    <rdf:Description rdf:about="&Ontology1334514742253;EntiteFabrication"/>
                    <owl:Restriction>
                        <owl:onProperty rdf:resource="&Ontology1334514742253;prepare"/>
                        <owl:someValuesFrom rdf:resource="&Ontology1334514742253;PiecePrepare"/>
                    </owl:Restriction>
                </owl:intersectionOf>
            </owl:Class>
        </owl:equivalentClass>
        <rdfs:subClassOf rdf:resource="&Ontology1334514742253;EntiteFabrication"/>
    </owl:Class>



    <!-- http://www.semanticweb.org/ontologies/2012/3/Ontology1334514742253.owl#EntiteFabMatiere -->

    <owl:Class rdf:about="&Ontology1334514742253;EntiteFabMatiere">
        <owl:equivalentClass>
            <owl:Class>
                <owl:intersectionOf rdf:parseType="Collection">
                    <rdf:Description rdf:about="&Ontology1334514742253;EntiteFabrication"/>
                    <owl:Restriction>
                        <owl:onProperty rdf:resource="&Ontology1334514742253;reçoit"/>
                        <owl:onClass rdf:resource="&Ontology1334514742253;MatiereFourni"/>
                        <owl:qualifiedCardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:qualifiedCardinality>
                    </owl:Restriction>
                </owl:intersectionOf>
            </owl:Class>
        </owl:equivalentClass>
        <rdfs:subClassOf rdf:resource="&Ontology1334514742253;EntiteFabrication"/>
    </owl:Class>



    <!-- http://www.semanticweb.org/ontologies/2012/3/Ontology1334514742253.owl#EntiteFabrication -->

    <owl:Class rdf:about="&Ontology1334514742253;EntiteFabrication">
        <rdfs:subClassOf>
            <owl:Restriction>
                <owl:onProperty rdf:resource="&Ontology1334514742253;VilleFab"/>
                <owl:allValuesFrom rdf:resource="&rdfs;Literal"/>
            </owl:Restriction>
        </rdfs:subClassOf>
        <rdfs:subClassOf>
            <owl:Restriction>
                <owl:onProperty rdf:resource="&Ontology1334514742253;NomFab"/>
                <owl:allValuesFrom rdf:resource="&rdfs;Literal"/>
            </owl:Restriction>
        </rdfs:subClassOf>
        <rdfs:subClassOf>
            <owl:Restriction>
                <owl:onProperty rdf:resource="&Ontology1334514742253;PaysFab"/>
                <owl:allValuesFrom rdf:resource="&rdfs;Literal"/>
            </owl:Restriction>
        </rdfs:subClassOf>
        <rdfs:subClassOf>
            <owl:Restriction>
                <owl:onProperty rdf:resource="&Ontology1334514742253;AdresseFab"/>
                <owl:allValuesFrom rdf:resource="&rdfs;Literal"/>
            </owl:Restriction>
        </rdfs:subClassOf>
    </owl:Class>



    <!-- http://www.semanticweb.org/ontologies/2012/3/Ontology1334514742253.owl#EntiteMarketing -->

    <owl:Class rdf:about="&Ontology1334514742253;EntiteMarketing">
        <rdfs:subClassOf>
            <owl:Restriction>
                <owl:onProperty rdf:resource="&Ontology1334514742253;NomMarketing"/>
                <owl:allValuesFrom rdf:resource="&rdfs;Literal"/>
            </owl:Restriction>
        </rdfs:subClassOf>
        <rdfs:subClassOf>
            <owl:Restriction>
                <owl:onProperty rdf:resource="&Ontology1334514742253;AdresseMarketing"/>
                <owl:allValuesFrom rdf:resource="&rdfs;Literal"/>
            </owl:Restriction>
        </rdfs:subClassOf>
        <rdfs:subClassOf>
            <owl:Restriction>
                <owl:onProperty rdf:resource="&Ontology1334514742253;VilleMarketing"/>
                <owl:someValuesFrom rdf:resource="&rdfs;Literal"/>
            </owl:Restriction>
        </rdfs:subClassOf>
        <rdfs:subClassOf>
            <owl:Restriction>
                <owl:onProperty rdf:resource="&Ontology1334514742253;PaysMarketing"/>
                <owl:allValuesFrom rdf:resource="&rdfs;Literal"/>
            </owl:Restriction>
        </rdfs:subClassOf>
    </owl:Class>



    <!-- http://www.semanticweb.org/ontologies/2012/3/Ontology1334514742253.owl#PiecePrepare -->

    <owl:Class rdf:about="&Ontology1334514742253;PiecePrepare">
        <rdfs:subClassOf>
            <owl:Restriction>
                <owl:onProperty rdf:resource="&Ontology1334514742253;NomPiecePreparer"/>
                <owl:allValuesFrom rdf:resource="&xsd;string"/>
            </owl:Restriction>
        </rdfs:subClassOf>
    </owl:Class>



    <!-- http://www.semanticweb.org/ontologies/2012/3/Ontology1334514742253.owl#ProduitFinalCommercial -->

    <owl:Class rdf:about="&Ontology1334514742253;ProduitFinalCommercial">
        <rdfs:subClassOf>
            <owl:Restriction>
                <owl:onProperty rdf:resource="&Ontology1334514742253;Nomprodfinal"/>
                <owl:allValuesFrom rdf:resource="&rdfs;Literal"/>
            </owl:Restriction>
        </rdfs:subClassOf>
        <rdfs:subClassOf>
            <owl:Restriction>
                <owl:onProperty rdf:resource="&Ontology1334514742253;DesignationProdFinal"/>
                <owl:allValuesFrom rdf:resource="&rdfs;Literal"/>
            </owl:Restriction>
        </rdfs:subClassOf>
    </owl:Class>












    <!-- http://www.semanticweb.org/ontologies/2012/3/Ontology1334514742253.owl#EntProduction2 -->

    <owl:NamedIndividual rdf:about="&Ontology1334514742253;EntProduction2">
        <rdf:type rdf:resource="&Ontology1334514742253;EntiteProduction"/>
        <Produit rdf:resource="&Ontology1334514742253;ProdFini3"/>
    </owl:NamedIndividual>



    <!-- http://www.semanticweb.org/ontologies/2012/3/Ontology1334514742253.owl#EntitFabLiv1 -->

    <owl:NamedIndividual rdf:about="&Ontology1334514742253;EntitFabLiv1">
        <rdf:type rdf:resource="&Ontology1334514742253;EntiteFabLiv"/>
        <rdf:type rdf:resource="&Ontology1334514742253;EntiteFabMatiere"/>
        <rdf:type rdf:resource="&Ontology1334514742253;EntiteFabrication"/>
        <owl:sameAs rdf:resource="&Ontology1334514742253;FabEntite1"/>
        <prepare rdf:resource="&Ontology1334514742253;PiecePrepa1"/>
        <prepare rdf:resource="&Ontology1334514742253;PiecePrepa3"/>
    </owl:NamedIndividual>



    <!-- http://www.semanticweb.org/ontologies/2012/3/Ontology1334514742253.owl#EntitFabLiv2 -->

    <owl:NamedIndividual rdf:about="&Ontology1334514742253;EntitFabLiv2">
        <rdf:type rdf:resource="&Ontology1334514742253;EntiteFabLiv"/>
        <rdf:type rdf:resource="&Ontology1334514742253;EntiteFabMatiere"/>
        <rdf:type rdf:resource="&Ontology1334514742253;EntiteFabrication"/>
        <owl:sameAs rdf:resource="&Ontology1334514742253;FabEntite2"/>
        <prepare rdf:resource="&Ontology1334514742253;PiecePrepa2"/>
        <prepare rdf:resource="&Ontology1334514742253;PiecePrepa4"/>
    </owl:NamedIndividual>



    <!-- http://www.semanticweb.org/ontologies/2012/3/Ontology1334514742253.owl#EntiteAssemCont1 -->

    <owl:NamedIndividual rdf:about="&Ontology1334514742253;EntiteAssemCont1">
        <rdf:type rdf:resource="&Ontology1334514742253;EntiteAssemblageControle"/>
        <rdf:type rdf:resource="&Ontology1334514742253;EntiteControle"/>
        <owl:sameAs rdf:resource="&Ontology1334514742253;EntiteContr1"/>
        <controle rdf:resource="&Ontology1334514742253;PiecePrepa1"/>
        <controle rdf:resource="&Ontology1334514742253;PiecePrepa2"/>
    </owl:NamedIndividual>



    <!-- http://www.semanticweb.org/ontologies/2012/3/Ontology1334514742253.owl#EntiteAssemblageCont2 -->

    <owl:NamedIndividual rdf:about="&Ontology1334514742253;EntiteAssemblageCont2">
        <rdf:type rdf:resource="&Ontology1334514742253;EntiteAssemblageControle"/>
        <rdf:type rdf:resource="&Ontology1334514742253;EntiteControle"/>
        <owl:sameAs rdf:resource="&Ontology1334514742253;EntiteContr2"/>
        <controle rdf:resource="&Ontology1334514742253;PiecePrepa3"/>
        <controle rdf:resource="&Ontology1334514742253;PiecePrepa4"/>
    </owl:NamedIndividual>



    <!-- http://www.semanticweb.org/ontologies/2012/3/Ontology1334514742253.owl#EntiteContr1 -->

    <owl:NamedIndividual rdf:about="&Ontology1334514742253;EntiteContr1">
        <rdf:type rdf:resource="&Ontology1334514742253;EntiteAssemblageControle"/>
        <rdf:type rdf:resource="&Ontology1334514742253;EntiteControle"/>
        <NomSControle>VSC</NomSControle>
        <AdresseControle>rue sidi maarouf rue 40</AdresseControle>
        <VilleControle>Casablanca</VilleControle>
        <PaysControle>Maroc</PaysControle>
    </owl:NamedIndividual>



    <!-- http://www.semanticweb.org/ontologies/2012/3/Ontology1334514742253.owl#EntiteContr2 -->

    <owl:NamedIndividual rdf:about="&Ontology1334514742253;EntiteContr2">
        <rdf:type rdf:resource="&Ontology1334514742253;EntiteAssemblageControle"/>
        <rdf:type rdf:resource="&Ontology1334514742253;EntiteControle"/>
        <VilleControle>Casablanca</VilleControle>
        <PaysControle>maroc</PaysControle>
        <NomSControle>C.A</NomSControle>
        <AdresseControle>bouskoura bloc C numéros 4</AdresseControle>
    </owl:NamedIndividual>
4

0 回答 0