Exportar UML a XMI
El formato de intercambio que toda herramienta UML dice hablar, y el relato honesto de qué mitad de tu modelo sobrevive al viaje.
6 min de lecturaXMI 2.5.11 de 3
01What XMI actually is
XMI is XML Metadata Interchange, and the word doing the work is metadata. It is a mechanical rule for serializing any MOF-based metamodel into XML, and UML is one such metamodel - so an XMI file is your model expressed as elements and attributes that follow the UML metamodel's own structure. A class becomes a packagedElement with xmi:type="uml:Class", its attributes become nested ownedAttribute elements, and a relationship becomes anAssociation with two memberEnd references.
That is the whole idea, and it explains both the strength and the famous weakness. The strength: any tool that implements the UML metamodel can read those elements, because they are not a vendor's invention. The weakness follows immediately - nothing in the UML metamodel says where a class sits on a canvas. Coordinates are not part of what XMI was designed to carry.
02What transfers, and what does not
| Element | Notation | What it means |
|---|---|---|
| Classifiers | Reliable | Classes, interfaces, components, actors, use cases - name, stereotype and package placement all arrive. |
| Attributes and operations | Reliable | Including types, visibility and multiplicity. The most valuable half of the file and the half nobody wants to retype. |
| Relationships | Reliable | Associations with both ends, generalizations, realizations and dependencies. |
| Diagram layout | Unreliable | Positions and sizes travel in a vendor extension the receiving tool usually ignores. Expect to re-lay-out. |
| Notes and constraints | Mixed | Comments generally survive; OCL constraints depend on whether both tools parse the same OCL version. |
| Tool-specific data | Lost | Colours, custom properties, requirement links, test cases. None of it is UML, so none of it is XMI. |
The pattern is worth stating once: XMI carries what UML defines, and nothing else. Every disappointment with the format comes from expecting it to carry something the metamodel never described. That is not a defect in XMI so much as an answer to a question people did not realise they were asking.
03Using it without being surprised
Three habits remove most of the pain. Export a small model first and open the XML in a text editor. Ten minutes reading the file tells you more about what your tool emits than any documentation will, and it is where you discover that the layout is in an extension block near the bottom.
Import into a scratch project, never over a real one. An import that partially matches an existing model is far harder to undo than one that arrives in an empty container you can throw away.
Budget for re-layout rather than hoping. A hundred-class model re-arranged into readable views is a day's work, and it is worth costing that in rather than treating it as a failure when it happens. If you need the pictures to survive exactly, the answer is not XMI - it is a native file format or an image export.
In one line each
- 01XMI serializes the UML metamodel, so it carries the model and not the picture.
- 02Classifiers, members and relationships transfer reliably between conforming tools.
- 03Layout travels in vendor extensions and usually does not survive - budget for re-layout.
- 04Anything that is not UML - colours, custom fields, requirement links - is not in the file.
- 05Read one exported file in a text editor before you rely on the format.
04Preguntas frecuentes
¿Para qué sirve XMI?
Para mover un modelo UML entre herramientas que no comparten formato de fichero. Es una serialización XML del metamodelo UML, así que transporta el modelo - clases, atributos, operaciones y relaciones - y no su imagen.
¿Por qué desaparece mi disposición al importar XMI?
Porque el intercambio de diagramas fue una parte opcional del estándar durante casi toda la vida de XMI, y las herramientas llenaron el hueco con extensiones propias. Los elementos llegan; las coordenadas que los colocaban en el lienzo se escribieron en un dialecto que la herramienta receptora no lee.
¿Merece la pena exportar a XMI?
Sí, cuando lo que hay que mover es el modelo. Para eso es la única opción independiente de fabricante, y volver a colocar un diagrama es una tarde mientras que reescribir cuatrocientas clases son dos semanas. Si lo que quieres es una imagen, exporta SVG o PNG.
Lecturas relacionadas