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] Error saving JenaOWLModel with SWRL Rules to file

Abhinav Varma abhinav_varma at sify.com
Fri Apr 9 18:00:08 PDT 2010


Hi,

I am working on a project where I need to work with ontologies in java. I am
reading an ontology into an OWLModel. I am also reading in another ontology
into an OntModel. Following which I am making SPARQL query on the OntModel
and hence taking out data from the OntModel into my data structure. Then, I
generate SWRL rules from the values stored in the data structure. The SWRL
rules generated are correct as I successfully copy-pasted (and also inferred
from) them in the Protege's Rules tab. Next, I am adding the SWRL rules to
the OWLModel using SWRLFactory in the following manner:

//'owlModel' HAS THE ONTOLOGY IN THE OWLModel FORMAT.
factory = new SWRLFactory(owlModel);

//'body' HAS THE BODY PART OF THE GENERATED RULE IN THE FORM:
//"SuperOntology:DTC_105.15(?a)^ SuperOntology:Active(?a,"no")^
SuperOntology:givesError(?a,?p)"

//'head' HAS THE HEAD PART OF THE GENERATED RULE IN THE FORM:
//" -> SuperOntology:Description(?p,"DTC_Inactive")"

imp = factory.createImp(body+head);

I am also adding all the variables used in the rules by
//VAR1 HAS VARIABLES LIKE 'a' OR 'p' ETC
variable1 = factory.createVariable(var1);



Lastly, I am saving the OWLModel ontology to the hard disk. It is here in
the last step that I am encountering a problem which I am not able to figure
out. The following stack is displayed:

Loading triples for: null
    Completed triple loading after 59 ms
Postprocess: Process entities with incorrect Java type (1 entities) ... 1 ms
Postprocess: Process metaclasses (3 metaclasses) ... 0 ms
Postprocess: Process subclasses of rdf:List (1 classes) ... 0 ms
Postprocess: Instances with multiple types (1 instances) ... 0 ms
Postprocess: Add inferred superclasses ... 0 ms
Postprocess: Process orphan classes (17 classes) ... 2 ms
Postprocess: Generalized Concept Inclusion (0 axioms) ... 3 ms
Postprocess: Abstract classes... 0 ms
Postprocess: Domain and range of properties... 10 ms
Postprocess: Possibly typed entities (2 resources) ... 0 ms
Updating underlying frames model in 0 ms
Apr 10, 2010 6:18:21 AM
edu.stanford.smi.protegex.owl.jena.parser.ProtegeOWLParser
doFinalPostProcessing
INFO: Updating underlying frames model in 0 ms
Loading triples for: null
    Completed triple loading after 135 ms
Postprocess: Process entities with incorrect Java type (1 entities) ... 0 ms
Postprocess: Process metaclasses (3 metaclasses) ... 0 ms
Postprocess: Process subclasses of rdf:List (1 classes) ... 0 ms
Postprocess: Instances with multiple types (10 instances) ... 2 ms
Postprocess: Add inferred superclasses ... 0 ms
Postprocess: Process orphan classes (17 classes) ... 0 ms
Postprocess: Generalized Concept Inclusion (0 axioms) ... 0 ms
Postprocess: Abstract classes... 0 ms
Postprocess: Domain and range of properties... 3 ms
Postprocess: Possibly typed entities (2 resources) ... 0 ms
Updating underlying frames model in 0 ms
Apr 10, 2010 6:18:21 AM
edu.stanford.smi.protegex.owl.jena.parser.ProtegeOWLParser
doFinalPostProcessing
INFO: Updating underlying frames model in 0 ms
... saving successful to: E:\out.owl

//SO LOADING THE FIRST ONTOLOGY INTO OWLMODEL IS DONE.
//DATA STRUCTURE TRAVERSAL BEGINS
//SWRL RULES ARE GENERATED AND ADDED TO THE OWLMODEL USING SWRLFACTORY

//NOW STARTING TO PRINT OWLMODEL TO FILE
SEVERE: Failed to save file file:/E:/OutWithRules.owl using Protege2Jena. --
com.hp.hpl.jena.shared.BadURIException: Only well-formed absolute URIrefs
can be included in RDF/XML output: <nullRule-4> Code:
57/REQUIRED_COMPONENT_MISSING in SCHEME: A component that is required by the
scheme is missing.
	at
com.hp.hpl.jena.xmloutput.impl.BaseXMLWriter.checkURI(BaseXMLWriter.java:829)
	at
com.hp.hpl.jena.xmloutput.impl.BaseXMLWriter.relativize(BaseXMLWriter.java:806)
	at com.hp.hpl.jena.xmloutput.impl.Unparser.wURIreference(Unparser.java:881)
	at com.hp.hpl.jena.xmloutput.impl.Unparser.wURIreference(Unparser.java:885)
	at com.hp.hpl.jena.xmloutput.impl.Unparser.wAboutAttr(Unparser.java:876)
	at
com.hp.hpl.jena.xmloutput.impl.Unparser.wIdAboutAttrOpt(Unparser.java:832)
	at
com.hp.hpl.jena.xmloutput.impl.Unparser.wTypedNodeOrDescriptionLong(Unparser.java:793)
	at
com.hp.hpl.jena.xmloutput.impl.Unparser.wTypedNodeOrDescription(Unparser.java:727)
	at com.hp.hpl.jena.xmloutput.impl.Unparser.wTypedNode(Unparser.java:700)
	at com.hp.hpl.jena.xmloutput.impl.Unparser.wObj(Unparser.java:640)
	at com.hp.hpl.jena.xmloutput.impl.Unparser.wObjStar(Unparser.java:317)
	at com.hp.hpl.jena.xmloutput.impl.Unparser.wRDF(Unparser.java:298)
	at com.hp.hpl.jena.xmloutput.impl.Unparser.write(Unparser.java:200)
	at
com.hp.hpl.jena.xmloutput.impl.Abbreviated.writeBody(Abbreviated.java:143)
	at
com.hp.hpl.jena.xmloutput.impl.BaseXMLWriter.writeXMLBody(BaseXMLWriter.java:500)
	at
com.hp.hpl.jena.xmloutput.impl.BaseXMLWriter.write(BaseXMLWriter.java:472)
	at com.hp.hpl.jena.xmloutput.impl.Abbreviated.write(Abbreviated.java:128)
	at edu.stanford.smi.protegex.owl.jena.JenaOWLModel.saveModel(Unknown
Source)
	at edu.stanford.smi.protegex.owl.jena.JenaOWLModel.save(Unknown Source)
	at edu.stanford.smi.protegex.owl.jena.JenaOWLModel.save(Unknown Source)
	at
edu.stanford.smi.protegex.owl.jena.protege2jena.Protege2Jena.saveAll(Unknown
Source)
	at edu.stanford.smi.protegex.owl.jena.JenaOWLModel.save(Unknown Source)
	at module2.main(module2.java:899)

Exception in thread "main" java.lang.NullPointerException
	at edu.stanford.smi.protegex.owl.jena.JenaOWLModel.save(Unknown Source)
	at module2.main(module2.java:899)
-- 
View this message in context: http://n4.nabble.com/Error-saving-JenaOWLModel-with-SWRL-Rules-to-file-tp1820053p1820053.html
Sent from the Protege OWL mailing list archive at Nabble.com.



More information about the protege-owl mailing list