Search Mailing List Archives


Limit search to: Subject & Body Subject Author
Sort by: Reverse Sort
Limit to: All This Week Last Week This Month Last Month
Select Date Range     through    

[protege-owl] SQWRL through Java

Michael Lodemann milo at informatik.uni-kiel.de
Wed Oct 15 01:57:53 PDT 2008


It is all strange.
Seems the sqwrl.owl is not imported.

I receive a SWRLParseException
"Invalid identifier: '^'."
while executing the query
SWRLImp imp = factory.createImp("Person(?p) ^ age(?p, ?a) ->
sqwrl:select(?p, ?a)");

and like before "Invalid atom name 'sqwrl:count'."
while executing the query
SWRLImp imp = factory.createImp("Query-2", "Person(?p) -> sqwrl:count(?p)");
or similar queries.

I'm really stuck. I hope someone can help me.

confused,
Michael


<snip>

package test;

import java.util.Collection;
import edu.stanford.smi.protegex.owl.ProtegeOWL;
import edu.stanford.smi.protegex.owl.model.OWLDatatypeProperty;
import edu.stanford.smi.protegex.owl.model.OWLModel;
import edu.stanford.smi.protegex.owl.model.OWLNamedClass;
import edu.stanford.smi.protegex.owl.model.OWLObjectProperty;
import edu.stanford.smi.protegex.owl.model.RDFIndividual;
import edu.stanford.smi.protegex.owl.swrl.model.SWRLFactory;
import edu.stanford.smi.protegex.owl.swrl.model.SWRLImp;

public class importando2 {

    public static void main(String[] args ){
        try{
            OWLModel owlModel = ProtegeOWL.createJenaOWLModel();

            OWLNamedClass personClass =
owlModel.createOWLNamedClass("Person");

            OWLDatatypeProperty ageProperty =
owlModel.createOWLDatatypeProperty("hasAge");
            ageProperty.setRange(owlModel.getXSDint());
            ageProperty.setDomain(personClass);

            OWLObjectProperty childrenProperty =
owlModel.createOWLObjectProperty("children");
            childrenProperty.setRange(personClass);
            childrenProperty.setDomain(personClass);

            RDFIndividual darwin = personClass.createRDFIndividual("Darwin");
            darwin.setPropertyValue(ageProperty, new Integer(1));

            RDFIndividual holgi = personClass.createRDFIndividual("Holger");
            holgi.setPropertyValue(childrenProperty, darwin);
            holgi.setPropertyValue(ageProperty, new Integer(33));

            SWRLFactory factory = new SWRLFactory(owlModel);
//            SWRLImp imp = factory.createImp("Query-1", "sameAs(Darwin,
Holger)");
            SWRLImp imp = factory.createImp("Person(?p) ^ age(?p, ?a) ->
sqwrl:select(?p, ?a)");

//            SWRLImp imp = factory.createImp("Query-2", "Person(?p) ->
sqwrl:count(?p)");
            Collection col = imp.getReferencedInstances();
            System.out.println("elements: "+col.toString());

        }catch(Exception error){
             System.out.println(error.getMessage());
         }
    }
}

</snip>



More information about the protege-owl mailing list