Is there a XSD for UML XMI files?
The header just contains namespace references.
<xmi:XMI xmi:version="2.1"
xmlns:uml="http://schema.omg.org/spec/UML/2.1"
xmlns:xmi="http://schema.omg.org/spec/XMI/2.1"
xmlns:thecustomprofile="http://www.sparxsystems.com/profiles/thecustomprofile/1.0">
The only file I've managed to track down is this http://www.omg.org/spec/XMI/20131001/XMI.xsd however this is just description of the XMI itself (Difference/Documentation), but not the UML.
That means that I have no knowledge of how the process the following
<generalization
xmi:type="uml:Generalization"
xmi:id="EAID_8CC13F09_BD19_406b_A4B4_37FB8B315EF0"
general="EAID_E1F9FAD6_2BDB_40ad_AAE2_E3935ADD1CDC"/>
as I have no way of knowing what is the type of general
(of course I can check against a global ID table, but that seems stupid to do for every single attribute and TextElement).
I would expect to have something like
<xsd:complexType name="Generalization">
<xsd:attribute name="general" type="xsd:IDREFS" use="optional"/>
...
</xsd:complexType>
Does the UML's XMI has such description?
An Attribute can appear 0 or 1 times within a given element in the XML document. Attributes are either optional or mandatory (by default they are optional). The "use" property in the XSD definition is used to specify if the attribute is optional or mandatory.
The XML Schema definition language (XSD) enables you to define the structure and data types for XML documents. An XML Schema defines the elements, attributes, and data types that conform to the World Wide Web Consortium (W3C) XML Schema Part 1: Structures Recommendation for the XML Schema Definition Language.
XML Schema Definition or XSD is a recommendation by the World Wide Web Consortium (W3C) to describe and validate the structure and content of an XML document. It is primarily used to define the elements, attributes and data types the document can contain.
The 'schemaLocation' attribute is used to reference XML Schema(s) that are defined in a target-namespace.
After some more digging, my conclusion is not only that such XSD doesn't exist, but that it can't exist at all, because it is not powerful enough to properly express all the OCL constrains and rules of UML.
The correct approach should be to validate/process it through a conforming UML model, so the necessary information to properly process the XML has to be somehow derived from the model.
Update:
Per @Thomas' suggestion I wrote to Sparx and got the following response
It's derived from the UML metamodel.
No, we don't have an XSD for the XMI format.
Which confirms my assumption that the information should be derived from the metamodel.
Yes, there is an official specification for XMI, including an XSD.
For the latest version (v 2.5.1) this is the xsd but this xsd will not validate the UML syntax of the model.
The meta-model of UML is available as well in xmi format
More info on http://www.omg.org/spec/XMI/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With