XMI is a standard which defines how to serialise object instances. Although XML is a very good way to store information in a tree structured way, it is not object oriented. XMI extends XML to make it object oriented.
So XMI needs to define elements and attributes to hold the object instance in a standard way.
Top Level Object
We can either include the root object in the body:
<xmi:XMI xmi:version="2.0" ...> <EuclideanSpace /> </xmi:XMI>
or with the version
<EuclideanSpace xmi:version="2.0" ...>
Identifying Objects
<EuclideanSpace xmi:id="_1" xmi:uuid="AB 123abcd" xmi:label="complex" / >
xmi:id
unique within document - used to specify relationships between objects.
xmi:uuid
globally unique (see DCE specification)
xmi:label
any other information
Attribute Values
Data Values
There are two forms for storing attribute values, we can store it in an attribute or an element.
Reference Values
Again there are two forms for storing reference values.
Using XMI to store UML Models
We can use XMI to store UML models. XMI is defined for storing object instances, however we can create instances of a meta model (possibly based on the Meta Object Facility (MOF) specification from the Object Management Group (OMG) ) .
The XMI schema also extends the XML schema so that definitions of objects can be stored. This provives a way to hold a UML model.
XMI Tags
XMI Tag | |
---|---|
xmiName | |
serialise | |
element | |
attribute | |
enforceMaximumMultipicity | |
enforceMinimumMultipicity | |
form | |
remoteOnly | |
href | |
includeNils | |
defaultValue | |
fixedValue | |
nsURI | |
nsPrefix | |
useSchemaExtensions | |
contentType | |
ordered |
An Example of an XMI file
I created the following very simple java classes:
package xmiexample;
public class dimension { double x,y,z; public dimension(x1,y1,z1) { x=x1; y=y1; z=z1; } public double getX(){ return x; } public double getY(){ return y; } public double getZ(){ return z; } }
package xmiexample;
public class box { dimension size; String name; public box() { } public String getName(){ return name; } public double getX(){ return size.getX(); } }