Generate Java Code Implementing OWL2 Ontologies

The xOWL Infrastructure has facilities for generating Java code that implement OWL2 ontologies. That is to say, you can create an OWL2 ontology with classes, properties, individuals and generate a Java implementation with Java classes representing the OWL2 classes, Java methods for setting values for properties, etc.

Modes

The XOWL Code Generator can operate on 2 modes:
  • Standalone: In this mode the generated Java code is independent from any library. That is to say, no xOWL library will be needed afterwards. The generated code can be included in your own project. This mode is great for implementing complex domain models for your own applications. In facts, the xOWL language constructs are themselves represented in OWL2 ontologies and their Java implementation is used by the XOWL Interpreter.
  • Proxy: In this mode the generated Java code will have the same interface that the standalone mode. The same classes and accessor methods will be generated. However, the generated code acts as a façade for the XOWL Interpreter. Using this mode, you can load an ontology with the XOWL Interpreter, access it through Java classes representing your domain model, and later save the modified data as an ontology. This mode has been used by the XOWL GMI Environment.

Features and Limitations

The XOWL Code Generator will try to implement at best the semantics of the OWL2 ontology. Supported OWL2 features in both modes include:
  • Complex OWL2 class hierarchy
  • Class unions and intersections
  • Property hierarchies
  • Inverse properties
  • Individuals (become static Java objects)
  • Punning (limited)
  • Reflection (limited)
Unsupported OWL2 features include:
  • Property chains
  • Keys

In Practice

  • Create an OWL2 ontology representing your domain. You may save it in the Functional, OWL/XML or RDF/XML format.
  • Build the XOWL Code Generator and XOWL Interpreter projects using Ant or NetBeans.
  • Create a configuration file for your case. You may find examples of such configuration file in XOWLCodeGenerator\scrips.
  • Run the XOWL Code Generator with the path to your configuration file in parameter. The generator will also compile the generated code so that its final output is a jar file.

The configuration file contains the following elements:
  • libs: Path to the library folder of the XOWL Interpreter. The jar in this folder will be loaded dynamically as needed.
  • repository: Path to the directory containing your ontology(ies).
  • input: Name of your ontology with their syntax. Accepted syntaxes are Functional, OWLXML and RDFXML.
  • basePackage: The generator will create a Java package for each ontology. The base package is the Java package name that will contain all of them.
  • mode: Native for standalone, or Proxy
  • output: The directory used as output for the Java code
  • jarName: The name of the jar file that will contain the compiled code
  • maxFileLength: The maximal length of generated file names.

Last edited May 10, 2012 at 1:12 PM by lwouters, version 3

Comments

No comments yet.