Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to generate XMI file for the java source code?

Tags:

java

xmi

I'm writing a program in java language which takes the java source code as an input and the output is xmi file which contains the class diagram of the source code.

I have researched for xmi structure but I was not able to find an adequate resource which explain the structure and order of tags.

First question is how can I found out what is the order of the tags and definition of each tag? for instance, what is the meaning of "isActive = false" etc?

Secondly, is there any suggestion of libraries or anything in java language which can help me to finish this project?

like image 953
Bernard Avatar asked Oct 21 '22 10:10

Bernard


1 Answers

I think the tag order doesn't matter in XMI. In general, XMI just defines how to map MOF to XML. So basically you build the M2 model (=UML) from Java and and then map this to XML with XMI if I understand this correctly (and I think the double indirection is why you don't find good resources for the mapping from UML to XMI directly).

For many people, examples may be more accessible than the chain of transformation rules defined by the various OMG standards. So I'd just draw a minimal UML example diagram in my favorite UML tool for the export aspect I am interested in and look at the exported XMI. Then add features as needed...

P.S.: You may want to use the Java reflection classes (package java.lang.reflect) instead of parsing the the Java source yourself to generate XMI (if you don't need to preserve method argument names).

like image 87
Stefan Haustein Avatar answered Oct 24 '22 02:10

Stefan Haustein