Skip to content

Files

Latest commit

fe084c9 · Jun 5, 2025

History

History
This branch is 51 commits behind apache/jena:main.

jena-ontapi

README.md

Apache Jena OWL2 Model

Summary

This is enhanced Apache Jena Inference RDF Model with OWL2 support.

Major components

  • OntModel - the main interface to work with OWL2 & OWL1 & RDFS ontologies
  • OntModelFactory - factory for creating different OntModel types
  • GraphRepository - graph store accessor
  • OntSpecification - encapsulates ReasonerFactory, OntConfig, OntPersonality
  • UnionGraph - a Graph implementation with support hierarchy
  • OntModelConfig - model configuration, defines what a model can do and what it cannot do
  • OntPersonality - a configuration class to conduct Jena's polymorphism for OntObjects

Supported specifications

  • OWL2 DL & Full: NO_INF, RULES_INF, RDFS_INF, TRANS_INF + BUILTIN_INF (default)
  • OWL2 EL: NO_INF, RULES_INF, RDFS_INF, TRANS_INF
  • OWL2 QL: NO_INF, RULES_INF, RDFS_INF, TRANS_INF
  • OWL2 RL: NO_INF, RULES_INF, RDFS_INF, TRANS_INF
  • OWL1 DL & Full: NO_INF, RULES_INF, RDFS_INF, TRANS_INF, MICRO_RULES, MINI_RULES
  • OWL1 Lite: NO_INF, RULES_INF, RDFS_INF, TRANS_INF
  • RDFS: NO_INF, RDFS_INF, TRANS_INF

Example

GraphRepository repository = GraphRepository.createGraphDocumentRepositoryMem();

OntModel m = OntModelFactory.createModel(OntSpecification.OWL2_DL_MEM_BUILTIN_INF, repository)
        .setNsPrefixes(OntModelFactory.STANDARD);

m.setID("ont").setVersionIRI("ont#v1");

OntObjectProperty p = m.createObjectProperty("p");
OntClass a = m.createOntClass("a");
OntIndividual i = a.createIndividual("i");
OntClass b = m.createOntClass("b")
        .addSuperClass(m.createObjectIntersectionOf(a, m.createObjectHasValue(p, i)));

m.ontObjects(OntClass.class).forEach(System.out::println);
m.ontObjects(OntIndividual.class).forEach(System.out::println);

m.write(System.out, "ttl");