EMF / XMI I/O
The kuml-io-emf module provides bidirectional exchange with the Eclipse Modeling
Framework (EMF) UML2 format. It covers two independent capabilities:
-
Model XMI — import/export of UML class models as
.umlXMI files. -
Profile XMI — import/export of kUML profiles as
.profile.umlXMI files (v0.20.0).
Both are JVM-only and loaded via reflection. They work with Enterprise Architect, Papyrus, and MagicDraw.
Model XMI (.uml)
Export
kuml export model.kuml.kts --format xmi --output model.uml
Writes a uml:Model root element in Eclipse UML2 XMI format. Supported elements:
Class, Interface, Enumeration, Association, Generalization, InterfaceRealization,
Dependency.
Profile XMI (.profile.uml)
v0.20.0 extends kuml-io-emf with bidirectional profile exchange using the standard
Eclipse UML2 uml:Profile root element.
Export a profile to XMI
kuml export autosar-profile.kuml.kts --format profile-uml --output autosar.profile.uml
The script must evaluate to a KumlProfile as its last expression. The profile is
written by ProfileXmiExporter to a .profile.uml file with a uml:Profile root.
Import a profile from XMI
import dev.kuml.io.emf.ProfileXmiImporter
val result = ProfileXmiImporter().importResult(File("autosar.profile.uml"))
when (result) {
is ProfileResult.Success -> println(result.profile.name)
is ProfileResult.Failure -> println(result.message)
}
importResult catches all Throwable and wraps failures in ProfileResult.Failure —
useful when the file origin is external (CI artifact, partner toolchain).
Roundtrip
import dev.kuml.io.emf.ProfileXmiExporter
import dev.kuml.io.emf.ProfileXmiImporter
val original: KumlProfile = autosarProfile()
ProfileXmiExporter().export(original, File("out.profile.uml"))
val roundTripped = ProfileXmiImporter().importResult(File("out.profile.uml"))
as ProfileResult.Success
A roundtrip preserves stereotype names, targetMetaclass, required/default/min tag
properties, and profile namespace / version.
Eclipse metaclass proxies require org.eclipse.uml2.uml.resources, which is not
available on Maven Central. kUML encodes the metaclass as a sentinel attribute
kuml_metaclass<Name> and recovers it on import — this means .profile.uml files
produced by kUML are not directly loadable by the Eclipse P2 toolchain without the UML
Resources bundle.
|
What round-trips
| Preserved | Limitation |
|---|---|
Stereotype names and |
Enum-typed tag properties fall back to |
Tag properties: name, type, required, default, min |
|
Profile namespace, version, description |
Eclipse-specific EAnnotations not produced by kUML are ignored |
|
— |
See also
-
Profiles — authoring profiles in the kUML DSL
-
AUTOSAR / ARXML I/O — AUTOSAR Classic toolchain exchange