Jena is a rule inference engine for Java, useful for the Semantic Web. It handles RDF and OWL. It can be integrated with Pellet.

  1. OWL Validation with Jena
  2. Jena Pygments Lexer

Sample Jena validation code


OntModel model = MomUtil.leOnto("ruleTest.owl");

String validationRule = "[validationRule: (?v rb:validation on()) -> " +
  "[(?X rb:violation error('conflict', 'x86 with MacOs', ?X)) <- " +
  "(?X rdf:type laico:PersonalComputer) (?X laico:hasArchitecture ?Z) (?Z rdf:type laico:X86)" +
  "(?X laico:hasOS ?O) (?O rdf:type laico:MacOS)]]";

PrintUtil.registerPrefix("laico", "");

List rules = Rule.parseRules(validationRule);
Reasoner reasoner = new GenericRuleReasoner(rules);
InfModel inf = ModelFactory.createInfModel(reasoner, model);
ValidityReport validityReport = inf.validate();

if (!validityReport.isValid()) {
  Iterator iterator = validityReport.getReports();
  while (iterator.hasNext()) {

You can also see the code involved in integrating Jena validation rules into IAML.

Relative URIs are not permitted in RDF

If you get this error when trying to load a model like so: Model model = FileManager.get().loadModel("file:tests/invalid.simple");

With the following model:

<?xml version="1.0" encoding="UTF-8"?>
<s:InternetApplication xmi:version="2.0" xmlns:xmi="" xmlns:s="">
  <pages name="page 1"/>
  <pages name="page 1"/>

This may be because your model does not have a root XML namespace:

<?xml version="1.0" encoding="UTF-8"?>
<s:InternetApplication xmi:version="2.0" xmlns:xmi="" xmlns:s="">
  <s:pages s:name="page 1"/>
  <s:pages s:name="page 1"/>

You might also be able to get around it by adding a root XML namespace through xmlns=””.

Enabling debug messages with Jena

Reasoner reasoner = ReasonerRegistry.getOWLReasoner();
reasoner.setParameter(ReasonerVocabulary.PROPtraceOn, true);
reasoner = reasoner.bindSchema(schema);

You will also need to set up Log4J.