tags:

views:

51

answers:

2

Hi All,

Is there any way i can read an XMI file by writing java code rather that using nay tool(like EMF, MDI etc)? I want to write a java program which can read all the classes and attributes in an xmi file and then load then in the memory.

Please help.

A: 

That´s quite easy. You just need to write a Java program that parses the XML File and look for the classes of the UML model (XML elements named "Class"). Attributs appear as nested elements (Classifier.feature and then Attribute)

Jordi Cabot
Hi Jordi,thanks for your reply. Actually i want to create a domain model for my project which will parse/read the different excel sheets and then will get the values of classes, relations and their instances. Hence i can not code the classes in the domain model directly as Java classes, and i have to implement a generic framework that can read any domain model (UML class diagram) from a file in a suitable format (XMI?).
chahal
So, i thought about the using xmi format for defining the uml classes format. Could you please tell me that am i going in right direction(by reading the xmi and store the classes,relationships in some variables and collection). Can you give me any other idea how to handle this situation?Thanks.
chahal
that´s exactly what I was saying. At the Java level you´ll have a UMLClass class, a UMLAttribute class,... and you will instantiate these classes with the info of the UML model obtained from the XMI file.
Jordi Cabot
A: 

You have 3 options.

  • Use an implementation of the JMI specification (didn't find any until now)
  • use ECore as a lib (or is that one really eclipse-dependant?)
  • Parse the XML with some XML-reader/-library and just pull what you need
Kissaki