简体   繁体   English

如何阅读XMI?

[英]How to read XMI?

I need to read UML diagrams that are serialized into XMI. 我需要阅读序列化为XMI的UML图。 Is there any library that would allow me to conveniently read UML XMI - by conveniently I mean having some methods to iterate over classes/packages/methods/attributest etc. in model. 是否有任何库可以让我方便地阅读UML XMI - 方便的是我有一些方法来迭代模型中的类/包/方法/属性等。

I tried EMF, but I am unable to find any tutorial that would show how to import XMI containing UML. 我试过EMF,但是我找不到任何教程来展示如何导入包含UML的XMI。 I have also found NSUML/NSMDF but the link to documentation is broken. 我也找到了NSUML / NSMDF但是文档的链接被破坏了。

I don't think what you want exists. 我不认为你想要什么。 All tools importing XMI that I know (including my XMI transformation service: http://modeling-languages.com/content/xmi2-tool-exchanging-uml-models-among-case-tools ) work by parsing the whole XMI file and creating the corresponding UML model in main memory. 导入我知道的XMI的所有工具(包括我的XMI转换服务: http//modeling-languages.com/content/xmi2-tool-exchanging-uml-models-among-case-tools )通过解析整个XMI文件来工作在主内存中创建相应的UML模型。 Then you can access to the UML elements by querying the model. 然后,您可以通过查询模型来访问UML元素。

To iterate on the XMI model you can easily use XML libraries to select the pieces of the XMI file you are interested in. 要迭代XMI模型,您可以轻松使用XML库来选择您感兴趣的XMI文件。

Maybe simply have a look at Transforming XMI to HTML . 也许只是简单地看看将XMI转换为HTML This should help you to get started with XSLT and XMI. 这应该可以帮助您开始使用XSLT和XMI。

It depends on the version of UML that you are trying to read. 这取决于您尝试阅读的UML版本。 The NSUML package that you found only works with UML 1.3. 您找到的NSUML包仅适用于UML 1.3。 The NetBeans MetaData Repository (MDR) will read handle UML 1.4 and UML 1.5. NetBeans元数据存储库 (MDR)将读取句柄UML 1.4和UML 1.5。 It can be used as a standalone library (that's what ArgoUML uses), so you don't need NetBeans. 它可以用作独立库(这是ArgoUML使用的),因此您不需要NetBeans。 For UML 2.x, I think the Eclipse EMF & UML2 libraries are your only choice. 对于UML 2.x,我认为Eclipse EMF和UML2库是您唯一的选择。 EMF is a dependency, but it's really the UML2 stuff that you want. EMF是一种依赖,但它确实是你想要的UML2。 Like with MDR and NetBeans, you don't need Eclipse. 与MDR和NetBeans一样,您不需要Eclipse。 ArgoUML uses the Eclipse libraries for its UML 2.x support. ArgoUML使用Eclipse库来支持UML 2.x.

ArgoUML可以将XMI导入其UML模型,并为Java,C ++,C#,PHP4和PHP5生成代码。

In order to read XMI/UML using EMF, you will need to find, generate or write ECore model for UML. 要使用EMF读取XMI / UML,您需要为UML查找,生成或编写ECore模型。 Once you have one of those, you can generate the in-memory classes for manipulating the UML and leverage the other EMF infrastructure. 一旦有了其中一个,就可以生成内存类来操作UML并利用其他EMF基础结构。

But a simpler route may be to use the UML2 infrastructure developed by the Eclipse MDT project . 但更简单的方法可能是使用Eclipse MDT项目开发的UML2基础结构。 (My guess is that it uses EMF under the hood and that there is an ECore model for UML2 in there somewhere.) (我的猜测是它在引擎盖下使用了EMF,并且某处有UML2的ECore模型。)

What you are looking for is the Java specification for JMI (“Java Metadata Interface”), which implements MOF for describing Metadata and XMI for transporting the Metadata. 您正在寻找的是JMIJava规范 (“Java元数据接口”),它实现了用于描述元数据的MOF和用于传输元数据的XMI。

Unfortunately I am currently looking for implementations of JMI myself and suns JMI page seems to be a bit outdated. 不幸的是,我目前正在寻找JMI的实现,而且太阳JMI页面似乎有点过时了。 The open source implementation by netbeans seems to have been dropped for version 6. 对于版本6,netbeans的开源实现似乎已被删除。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM