问题
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?
回答1:
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.
回答2:
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/
来源:https://stackoverflow.com/questions/36845695/does-uml-have-an-xsd-for-its-xmi