我必须使用 JAXB 解析 XMI 文件(xmi 版本 2.1.1)。
为此,我必须生成与 XMI 文件相对应的 Java 类。
因此,我需要 xmi 文件的 shema 定义才能使用 jxc 工具执行此操作。
我希望有人知道在哪里可以找到这个文件。
预先感谢您的帮助!
编辑:有关更多信息,有一个 xmi 文件的示例(使用 modelio 生成):
<?xml version="1.0" encoding="UTF-8"?>
<uml:Model xmlns:uml="http://schema.omg.org/spec/UML/2.1.1" xmlns:xmi="http://schema.omg.org/spec/XMI/2.1" xmi:version="2.1" xmi:id="_1cUA4Pm5EeKGw-fe2JKgbQ" name="test">
<eAnnotations xmi:id="_1cUA4fm5EeKGw-fe2JKgbQ" source="Objing">
<contents xmi:type="uml:Property" xmi:id="_1cUA4vm5EeKGw-fe2JKgbQ" name="exporterVersion">
<defaultValue xmi:type="uml:LiteralString" xmi:id="_1cUA4_m5EeKGw-fe2JKgbQ" value="2.2"/>
</contents>
</eAnnotations>
<ownedComment xmi:type="uml:Comment" xmi:id="_1cUA5Pm5EeKGw-fe2JKgbQ">
<body/>
</ownedComment>
<packagedElement xmi:type="uml:Class" xmi:id="_1cUA5fm5EeKGw-fe2JKgbQ" name="User">
<ownedAttribute xmi:type="uml:Property" xmi:id="_1cUA5vm5EeKGw-fe2JKgbQ" name="login" visibility="private" isUnique="false" isReadOnly="true">
<type xmi:type="uml:PrimitiveType" href="http://schema.omg.org/spec/UML/2.1.1/uml.xml#String"/>
</ownedAttribute>
<ownedAttribute xmi:type="uml:Property" xmi:id="_1cUA5_m5EeKGw-fe2JKgbQ" name="id" visibility="private" isUnique="false" isReadOnly="true">
<type xmi:type="uml:PrimitiveType" href="http://schema.omg.org/spec/UML/2.1.1/uml.xml#Integer"/>
</ownedAttribute>
</packagedElement>
<packagedElement xmi:type="uml:Association" xmi:id="_1cUA6Pm5EeKGw-fe2JKgbQ" memberEnd="_1cUA6fm5EeKGw-fe2JKgbQ _1cUA7fm5EeKGw-fe2JKgbQ">
<ownedEnd xmi:type="uml:Property" xmi:id="_1cUA6fm5EeKGw-fe2JKgbQ" type="_1cUA6_m5EeKGw-fe2JKgbQ" association="_1cUA6Pm5EeKGw-fe2JKgbQ">
<lowerValue xmi:type="uml:LiteralInteger" xmi:id="_1cUA6vm5EeKGw-fe2JKgbQ"/>
</ownedEnd>
</packagedElement>
<packagedElement xmi:type="uml:Class" xmi:id="_1cUA6_m5EeKGw-fe2JKgbQ" name="Group">
<ownedAttribute xmi:type="uml:Property" xmi:id="_1cUA7Pm5EeKGw-fe2JKgbQ" name="label" visibility="private" isUnique="false" isReadOnly="true">
<type xmi:type="uml:PrimitiveType" href="http://schema.omg.org/spec/UML/2.1.1/uml.xml#String"/>
</ownedAttribute>
<ownedAttribute xmi:type="uml:Property" xmi:id="_1cUA7fm5EeKGw-fe2JKgbQ" name="user" type="_1cUA5fm5EeKGw-fe2JKgbQ" isReadOnly="true" aggregation="shared" association="_1cUA6Pm5EeKGw-fe2JKgbQ">
<upperValue xmi:type="uml:LiteralUnlimitedNatural" xmi:id="_1cUA7vm5EeKGw-fe2JKgbQ" value="*"/>
<lowerValue xmi:type="uml:LiteralInteger" xmi:id="_1cUA7_m5EeKGw-fe2JKgbQ"/>
</ownedAttribute>
</packagedElement>
</uml:Model>
您可以在 OMG 网站上找到 XMI XSDXMI XSD 2.1.1 http://www.omg.org/spec/XMI/20071001/07-10-06.xsd但你还需要统一建模语言模式 http://www.omg.org/spec/UML/20061001/Superstructure.cmof和MOF 架构 http://www.omg.org/spec/XMI/20100901/MOF.xmi.
读写 UML XMI 文件的更好方法是使用Eclipse UML 实现 http://wiki.eclipse.org/MDT-UML2。
它可以在 Eclipse 之外的简单 Java 程序中轻松使用:see http://www.eclipse.org/forums/index.php/mv/msg/360956/885947/#msg_885947
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)