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

Samson Tu swt at stanford.edu
Thu Oct 16 10:08:18 PDT 2008


Had you set " -Dprotege.dir=YourProtegeInstalationDirectory" as a Java 
VM argument when you invoke your application? It tells Protege where to 
load sqwrl.owl.

Samson

Michael Lodemann wrote:
> 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>
> _______________________________________________
> protege-owl mailing list
> protege-owl at lists.stanford.edu
> https://mailman.stanford.edu/mailman/listinfo/protege-owl
> 
> Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03 
> 




More information about the protege-owl mailing list