edit this page - page history - about editing


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

From http://tech.groups.yahoo.com/group/jena-dev/message/17639.

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", "http://laico.cic.unb.br/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="http://www.omg.org/XMI" xmlns:s="http://openiaml.org/simple">
  <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="http://www.omg.org/XMI" xmlns:s="http://openiaml.org/simple">
  <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="http://openiaml.org/simple".

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.
Categories: Java | Semantic Web
edit this page - what links to here? - page history - top
Last edited by jevon jevon 72 months ago