uml2semantic v0.0.3: XMI Support for UML-to-OWL Conversion

uml2semantics converts UML class diagrams into OWL 2 ontologies, enabling you to reason over your conceptual models and discover inconsistencies or unintended consequences. The UML-to-OWL translation is based on UML to OWL, which provides the related Manchester syntax and SROIQ semantics.

uml2semantics v0.0.3 now supports reading of XMI files. Previously, users had to manually create TSV files to describe their classes and attributes. With XMI support, you can now export your UML class diagram directly from a modelling tool like Enterprise Architect and feed it straight into uml2semantics.

Why does XMI matter? Many organisations already maintain UML class diagrams in modelling tools, such as Sparx Enterprise Architect, representing the core entities of their enterprise data. To make their data Findable, Accessible, Interoperable and Reusable (FAIR), and AI-Ready, being able to describe their data by ontologies, is an essential step.

Getting Started

  1. Download uml2semantics.jar from the latest release
  2. Requires Java 11+
  3. Run with your XMI file:
java -jar uml2semantics.jar \
-m "your-model.xml" \
-o "output.rdf" \
-p "prefix:http://your-ontology-iri#" \
-i "http://your-ontology-iri/v1"

See the README for the full CLI parameter reference and additional examples.

Example: Generating OWL from an XMI File

Consider the following UML class diagram, which includes a generalization set with Complete and Overlapping constraints:

In this diagram, Person is the superclass of Employee and Employer, with a generalization set marked as {complete, overlapping}. This means every Person is at least either an Employee or an Employer (complete), but it is also possible that Person are both (overlapping).

To convert this XMI file to an OWL ontology, run:

java -jar uml2semantics.jar \
-m "./examples/xmi/sparx/Employer-WithGeneralizationSet-CompleteOverlapping.xml" \
-o "./uml2semantics/examples/xmi/sparx/Employer-WithGeneralizationSet-CompleteOverlapping.rdf" \
-p "emp:http://uml2semantics.org/examples/employer#" \
-i "http://uml2semantics.org/examples/employer/v.0.1"

This produces an OWL ontology at the specified output path. Because the generalization set is Complete and Overlapping, uml2semantics generates an owl:equivalentClass axiom stating that Person is equivalent to the union of Employee and Employer.

Example: Combining TSV and XMI with TSV Override

A feature of uml2semantics is the ability to combine XMI and TSV inputs using the --overrides option. This is particularly useful when you want to integrate your UML model with existing linked data vocabularies, such as Schema.org.

For instance, suppose you want the Person class in your ontology to use the Schema.org IRI http://schema.org/Person, instead of the auto-generated http://uml2semantics.org/examples/employer#Person. You can achieve this with a TSV override file for classes:

CurieNameDefinitionParentNames
schema:PersonPerson

Similarly, you can map attributes to Schema.org properties. The following TSV override maps the name attribute to schema:givenName and surname to schema:familyName:

ClassCurieNameClassEnumOrPrivitiveTypeMinMultiplicityMaxMultiplicityDefinition
Personschema:givenNamenamexsd:string
Personschema:familyNamesurnamexsd:string

Now run uml2semantics with both the XMI file and the TSV overrides:

java -jar uml2semantics.jar \
-m "./examples/xmi/sparx/Employer-WithGeneralizationSet-CompleteOverlapping.xml" \
-c "./examples/xmi/sparx/Employer - Classes.tsv" \
-a "./examples/xmi/sparx/Employer - Attributes.tsv" \
--overrides TSV \
-o "./uml2semantics/examples/xmi/sparx/Employer-WithGeneralizationSet-CompleteOverlapping-TSVOverride.rdf" \
-p "emp:http://uml2semantics.org/examples/employer#" \
-i "http://uml2semantics.org/examples/employer/v.0.1"

The result: the Person class now has the IRI http://schema.org/Person, and its name and surname attributes use schema:givenName and schema:familyName respectively. The rest of the model — the generalization set, associations, and other classes — comes from the XMI file as before.

This approach is valuable when integrating existing UML class diagrams with linked data. Overrides are not limited to CURIEs — you can add entirely new classes and attributes via TSV that don’t exist in the XMI.

What XMI Features Are Supported

  • Classes with attributes — including name, type, and multiplicity
  • Generalizations (inheritance) — subclass/superclass relationships
  • Generalization sets with all four constraint combinations:
    • Complete + Disjoint — translated to owl:DisjointUnion
    • Complete + Overlapping — translated to owl:equivalentClass with owl:unionOf
    • Incomplete + Disjoint — translated to owl:AllDisjointClasses
    • Incomplete + Overlapping — translated to subclass relationships only
  • Associations between classes — translated to OWL object properties

Note: enumerations are not yet supported.

Conclusion

If uml2semantics is of interest to you, please let me know:

  1. What features will you like to see in this tool?
  2. If you are using a different modelling tool, it will be very helpful if you can provide an example XMI export and image of your UML class diagram. XMI is supposed to be standard, but as we all know, standards are made to be broken :-).

Introduction to ontology semantics and reasoning

I recently had the pleasure to present at the OntoSpot meeting at EBI to help my colleagues gain an intuitive understanding of ontology semantics and reasoning. In this talk I assume that you have a very basic understanding of what an ontology is, but I assume no previous knowledge wrt logic. I provide a number of examples and graphics to explain logic and description logic (DL) concepts.

Here I provide both the slides of this presentation and the link to the recording. If you have any questions or suggestions, please let me know in the comments. I have already had the very helpful suggestion for adding a reference of DL symbols, which I will do shortly.

Errata:

  1. In the section on speaking about propositional logic, I accidentally said predicate logic instead of propositional logic.
  2. At the end while answering questions, I said RFD rather than RDF.

This video will also be made available at the OBO Academy.

EquivalentTo versus SubClassOf

In creating their first OWL ontology, there are at least two aspects of EquivalentTo and SubClassOf that perplex users. The first is when to use EquivalentTo and when to use SubClassOf. The second problem is best illustrated by the following example:


ObjectProperty: a_to_b

Class: A1
   EquivalentTo: (a_to_b some B)

Class: A2
   SubClassOf: (a_to_b some B)

Class: B

Individual: b1
   Types: 
       B

Individual: x
   Facts:  
       a_to_b  b1

When running a reasoner on this example, the individual x is inferred to be of type A1. What perplex users sometimes is that x is not inferred to be of type A2 as well. This is shown in the next figure.

x inferred to be of type A1

The difference between EquivalentTo and SubClassOf

The first thing to be aware of wrt equivalentTo is that

Class: C
   	EquivalentTo: D

is an abbreviation for

Class: C
    SubClassOf: D
	
Class: D
    SubClassOf: C

The semantics of SubClassOf is subset. Thus, the above states that the set C is a subset of the set D and the set D is a subset of the set C. Which means that the sets C and D are exactly the same set. We say they are equivalent.

Note that if I know that the classes C1 and C2 are both subclasses of class C, there is nothing more I can say about how class C1 relates to class C2. This is a bit like knowing that bicycles and trucks are both vehicles – I can say nothing more about how bicycles relate to trucks beyond knowing that they are both vehicles.

Back to our initial example

Understanding the semantics of EquivalentTo we can see that indeed the individual x is an instance of A1. Understanding the semantics of SubClassOf helps us to understand why x is not inferred to be of type A2. We know that A2 is a subclass of a_to_b some B and that x is an instance of a_to_b some B, but there is nothing that can force the reasoner to infer that x is necessarily an instance of the class A2. This is illustrated in the next figure.

A2 and x wrt the set (a_to_b some B)

When to use EquivalentTo versus SubClassOf

EquivalentTo is used for definitions. That is when you want to state the necessary and sufficient conditions for a concept.

SubClassOf is used when you want to define a hierarchy from the most general to the most specific. I.e., it is typically what you see in taxonomies or in object oriented programming languages where one can define class hierarchies. In fact there is a strong relation between OWL 2 ontologies and object orientation which I explore here in more detail.

Conclusion

In this post I explained the difference between EquivalentTo versus SubClassOf and how they are used, as well as some inferences thatmay be confusing to new users. You can find the example ontology on GitHub.