Converting UML to OWL Ontology - uml

I am trying to develop an OWL ontology based on different UML file resources presented in XMI format. Reading through the internet for a while now, it seems that almost all the available tools or approaches are outdated and even when trying some of them they don't provide the expected outcome.
Since this ontology plays a really important role in our project, I wanted to know what is the best approachs/tools to be used in order to convert UML to OWL ?

I have looked into this myself as well and I have found no tools that can do this satisfactory. Problems I ran into were either the tools used an old version of UML, did not support all UML features, used OWL 1 rather than OWL 2 and was supported by only an old version of Protege.
I resorted by doing the translation by hand, which for most UML constructs are not too difficult. For this purpose I have done a write-up on UML vs OWL, which gives an intuitive explanation for why some of the translation is done in a certain why, as well as provide a reference for translating UML to OWL.

There's an OMG spec now available at https://www.omg.org/spec/MOF2RDF/
I haven't yet found an open-source tool implementing this directly (i.e. convert from UML/XMI to OWL/RDF), but there are EMF related activities, that may be relevant (haven't tried), e.g.:
https://github.com/ghillairet/emftriple

You'll probably never get exactly what you want unless you do it by hand, as Henriette mentioned. One viable option is using COGS, which I've found to work pretty well.
The catch is that it's related to Rot's answer by supporting the OMG specification. If it's not much work to make sure that your UML conforms to that specification, it may save some time in the long run. Here's an example of an OWL file produced by COGS.

Related

Saving UML model as XMI ambiguity

I found this sentence in article about XMI on wikipedia:
At the moment there are several incompatibilities between different
modeling tool vendor implementations of XMI, even between interchange
of abstract model data.
I wondered how it is possible that, despite using a well-documented standard, tools are not compatible. After looking through documentations of UML and XMI and through other people's questions I found out that there is no XML scheama or DTD for UML models saved as XMI.
According to the best answer to this question -https://stackoverflow.com/a/36885550/9329778 -the correct approach to check if XMI is well formed should be to validate/process it through a conforming UML model.
I also found this in XMI 2.5.1 documentation in section "7.3.2 Model Class Representation":
By default, XMI allows you to serialize features using either XML
elements or XML attributes; however, XMI allows you to specify how to
serialize them if you wish.
This looks to me like a source of the problem.
My questions are:
Is there an official guide that strictly describes how to save UML model using XMI? I don't mean the UML syntax meatamodel (which can be downloaded from OMG website).
If the answer to the first question is "no" - does it mean that different modeling tools can perform serialization of the same UML model differently even if they use the same version of XMI?
the reference is this current document by OMG
Though there is a "standard" the people which defined it are from different vendors under the hat of OMG. Of course every vendor tries to keep his sheep dry and warm (and likely if possible leave those of others in the rain - well). This simply lead to a standard which is open to anyone. While OMG ("trying" to holding its hand over such standards) allowed the addition of vendor individual extensions to pass, each vendor took advantage and used this addendum to his own favor. And that's what we see in different fora: why can't I import my model (completely/at all) from vendor A's tool into vendor B's tool. It's a cross.
Note: regarding 1: No. You can not take this document and create XMI from a model. It's not written that way. What I did was to create a simple model, export it (from my favorite tool) and see what had been created. Then I tried to import that into another tool (finding to where it fails). Or even export and import in the same tool to find what was missing afterwards.

Standard UML file format

I have designed UML diagrams in different tools (StarUML, BoUML, Papyrus, Omondo, Rational Rose, etc.) depending on the project and the date (rose was first, after Omondo, then starUMl, ..., now papyrus). However, I see that I cannot open my old UML diagrams because the tool is obsolete.
I would like to know if there is a standard format for UML diagrams. Probably not in production, but at least to know if there is proposal of standard format.
Probably, Eclipse is doing something like that with the M2 project, but do the other tools (not eclipse based) are interested in reading this format.?
Each UML tool uses its own format, but I think the era of proprietary format is over, and open format for diagrams like this should exist.
I have two answers to this:
In theory the standard exchange format for UML models is XMI but it´s true that each vendor implements a slightly different version so interchange is not a reality. Nevertheless, most tools are converging to at least support the Eclipse MDT-UML2 XMI implementation which in my opinion is becoming de facto XMI standard.
The OMG is working on a new standard : Diagram Definition that is supposed to fix the problems with the current XMI one (they are working a lot with many of the top vendors to make sure that this time they all go in the same direction) and, also important, it will allow to interchange not only the data (i.e. the info about the model elements) but also the layout and graphical representation so that after the import you get a model exactly as the same you exported in the first place
Have you heard of XMI?
#JordiCabot here adds some interesting details about it.
Besides Jordi's reference to the Diagram Definition standardization activity, please note that there is another action ongoing from OMG:
a request for comments has been issued in June 2011 for a CANONICAL XMI format, which is basically a subset and a set of additional rules for writing XMI documents that should limit the possibility of creating different XMI dialects, or at least should allow tools to understand a common dialect (the canonical one).

Is there any value in learning UML?

I have seen UML mentioned several places in the last few years, but never had a compelling reason to use it at work so far. Is there any value in putting the time and effort to learn it? (I am a Ruby on Rails developer.)
Edit: I'm also looking for stories about how UML has made a difference in your projects to give me an idea of how I might use it.
Yes. It is the international standard methodology for systems analysis and design. When moving from the initial analysis phase through the project life-cycle, the UML gives a good road-map on where to go and how you got there. A few benefits:
It shows requirements in a way that clients / customers / management can understand.
You can iterate the model and not lose track of where the model was before
Shows exactly how you got from point A to point B
It's a standard, so anyone who knows UML will be able to interpret your diagrams
The "quickest" way to share ideas without needing to go through the entire code-base
No, save your time and don't learn it. If you are a coder and work alone and are a very careful person, you can completely ignore UML.
But, if you work with other people and want to share the result of your work, UML is a Unified language, a lingua franca that even non technical customers understand (at a certain level).
Yes and no.
Yes, learn the basics. Have a quick look at at the different diagram types etc. and have a general idea. That will help you eliminate your hesitance when someone boasts about UML.
No, if your work doesn't require to work with UML, you don't necessarily need to know UML to write good applications. If you need to discuss something on a white board just draw a few circles. That'll do.
It only helped me to produce documentation to management to impress them a little. Other than that I only find the deployment diagrams somewhat useful, that's all.
If you look at UML as a merely graphical language you consider just a very small part of it. You should instead look at UML as the primary language of the Model Driven Architecture framework which is very well implemented in Eclipse.
In Eclipse UML is (correctly) considered as a Platform Independent language with a solid syntax defined by the MOF (ECORE in Eclipse) and semantics defined by the UML specification (http://www.omg.org/spec/UML).
In Eclipse there are good implementation of the two main languages defined by the OMG for Model To Text and Model to Model transformation specifications which are respectively MOFM2T (ACCELEO in Eclipse) and QVT.
Also Eclipse provides an implementation of the Object Constraint Language (OCL) which is used by both QVT and MOFM2T to evaluate queries on models.
All this means you can easily define your own Model to Text and Model to Model transformations , in the form of Eclipse plugin, turning your UML models into whatever you need.
Now I use that to automatically generate thousands of LOC, documentation and tests with an impressive return on investment.
However I know the majority of people doesn't even know UML is a language but think it is just about tiny pictures.
Look at this links for some simple example
http://lowcoupling.com/post/46522537374/the-model-driven-architecture
http://lowcoupling.com/post/47800863669/qvt-in-place-transformations
http://lowcoupling.com/post/47347056110/models-to-text-transformations-with-mofm2t-and-acceleo
I think it's a question of scale in two dimensions: size of problem and size of team.
When a design gets to a certain size diagrams become useful in two ways: first, they help you reason about design issues. second they help you communciate the design to other poeople.
So if the team is say 20 or 30 it really does help to have some clear documentation of pieces of the overall design.
Personally I use UML maybe four or five times a year, but when I need it, I really need it. It really is better to ase a standard diagramming technique that devise your own. And with good tools it's pretty painless.
I would say that I use only a small subset of UML, class diagrams and occasional collaboration diagrams.

How do I view UML in XML format in a diagrammatical format?

I am running UBUNTU. Linux and have tried BOUML, which can show the project in a tree structure, but I am unable to get a diagrammatical over view of the whole system.
I think this is not a direct programming question, but hopefully it can be answered here anyway. :)
Also, would appreciate a good place to start to learn more about UML as it is becoming increasingly important in my project management.
I am not sure what format you have at hand, but I assume, you have XMI and that format does not contain any diagram specific information, it is only about the model, which is represented usually using tree structure, because it is the easiest way. For a diagram you would need to visualize the model and most importantly use some sort of layout algorithm. Layout for large models is quite hard especially with many associations and automatic layout might produce diagrams, which are misleading.
There are many books and places where to start with UML. I would recommend a book, e.g. one from Martin Fowler or Ila Neustadt and Jim Arlow. Recently modeling languages portal released list of UML cheatsheets.

How to design a UML diagram with a scripting language?

I'm designing a software component which will get instructions from other components on how the UML diagram should look like, and then will produce this UML diagram in different presentation ways (in SVG, GIF, etc.), for example (in Java):
DiagramDesigner designer = new DiagramDesigner();
designer.setStyle('Use Cases')
designer.addActor('User');
designer.addUseCase('Print Document');
// etc.
String svg = designer.getSvg();
I don't want to re-invent the wheel and want to use some industry-standard language/interface for interconnection between my DiagramDesigner and other components. I'm looking for an interface similar to DOM, but for UML, not for XML.
Can anyone help? Thanks in advance.
ps. Besides the example above I would like to make my diagrams inter-operable and transferrable between servers, e.g.:
// first server
String script = designer.getScript();
// second server
DiagramDesigner desiger2 = DiagramDesigner.import(script);
So if I understand you right, you are looking for a way to work with UML on the metamodel level. You should look at the MOF standard and its implementation the EMF (Eclipse Modeling Framework), which is used by almost all Eclipse based UML tools and this framework is used by many other modeling projects, it even somewhat influenced the standardization of MOF (resulting in SMOF and EMOF split) and therefore I would declare it industry standard.
Probably only loosely related but anyhow: PlantUML. It is open source, built in Java and likely contains already parts of what you want to do.
You can inspire from these scripts to generate any output you want:
http://askuml.com/
Currently examples are given in yUML because they're nice but could be anything.
At least for the syntax part, you could get some inspiration from the large set of textual UML tools (theses tools allow designers to textually specify the model and then they automatically show the model graphically using the standard UML notation).
At least of such tools here: http://modeling-languages.com/content/uml-tools#textual

Resources