Class
XMIParser
Parser for XMI (XML Metadata Interchange) files
actor XMIParser
Overview
The XMI parser converts XMI files into EMF-compatible object graphs stored in Resources. It handles:
-
Metamodel (.ecore) files with full Ecore support
-
Model instance (.xmi) files with arbitrary user-defined attributes
-
Dynamic attribute parsing without hardcoded attribute names
-
Automatic type inference for Int, Double, Bool, and String values
-
Cross-resource references via href attributes (creates
ResourceProxyfor external refs) -
XPath-style fragment identifiers
-
Bidirectional reference resolution
Cross-Resource References
When parsing an href attribute with an external URI (e.g., href="department-b.xmi#/"), the parser creates a ResourceProxy instead of resolving immediately. The proxy can be resolved later using ResourceProxy.resolve(in:), which will automatically load the target resource if needed.
Same-resource references (e.g., href="#//@employees.0") are resolved to EUUID values during the two-pass parsing process.
Supported XMI Features
-
XMI Version: 2.0 and later
-
Ecore Metamodel: Full support for EPackage, EClass, EEnum, EDataType, EAttribute, EReference
-
Dynamic Attributes: Arbitrary XML attributes parsed without hardcoding (EMF spec compliant)
-
Type Inference: Automatic conversion of string values to Int, Double, Bool, or String
-
References: Same-resource (#//ClassName) and external (ecore:Type http://…)
-
Multiplicity: lowerBound and upperBound attributes
-
Containment: Containment references and opposite references
-
Default Values: defaultValueLiteral for attributes
Usage Example
let parser = XMIParser()
let resource = try await parser.parse(ecoreURL)
let roots = await resource.getRootObjects()
Topics
Initializers
Initialises a new XMI parser.
Instance Methods
Enable or disable debug mode for systematic tracing
Parse an XMI file and return a Resource containing the objects
Default Implementations
Relationships
Conforms To
See Also
Resources and Serialisation
A resource manages model objects and provides EMF-compliant reference resolution.
A resource set manages multiple resources and enables cross-resource reference resolution.
Serialises EMF objects to XMI (XML Metadata Interchange) format
Parser for JSON files in emfjson/pyecore format
Serializes EMF objects to JSON format (emfjson/pyecore compatible)