java 如何阅读 XMI?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2304085/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-29 20:30:53  来源:igfitidea点击:

How to read XMI?

javaxmlparsingumlxmi

提问by kane77

I need to read UML diagrams that are serialized into XMI. 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.

我需要阅读序列化为 XMI 的 UML 图。是否有任何库可以让我方便地阅读 UML XMI - 方便我的意思是有一些方法来迭代模型中的类/包/方法/属性等。

I tried EMF, but I am unable to find any tutorial that would show how to import XMI containing UML. I have also found NSUML/NSMDFbut the link to documentation is broken.

我尝试过 EMF,但找不到任何教程来展示如何导入包含 UML 的 XMI。我还找到了NSUML/NSMDF,但文档链接已损坏。

采纳答案by Jordi Cabot

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. Then you can access to the UML elements by querying the model.

我不认为你想要的存在。我知道的所有导入 XMI 的工具(包括我的 XMI 转换服务:http: //modeling-languages.com/content/xmi2-tool-exchange-uml-models-among-case-tools)通过解析整个 XMI 文件和在主内存中创建相应的 UML 模型。然后您可以通过查询模型来访问 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 文件部分。

回答by Pascal Thivent

Maybe simply have a look at Transforming XMI to HTML. This should help you to get started with XSLT and XMI.

也许只是看看Transforming XMI to HTML。这应该可以帮助您开始使用 XSLT 和 XMI。

回答by Tom Morris

It depends on the version of UML that you are trying to read. The NSUML package that you found only works with UML 1.3. The NetBeans MetaData Repository(MDR) will read handle UML 1.4 and UML 1.5. It can be used as a standalone library (that's what ArgoUML uses), so you don't need NetBeans. For UML 2.x, I think the Eclipse EMF & UML2 libraries are your only choice. EMF is a dependency, but it's really the UML2 stuff that you want. Like with MDR and NetBeans, you don't need Eclipse. ArgoUML uses the Eclipse libraries for its UML 2.x support.

这取决于您尝试阅读的 UML 版本。您发现的 NSUML 包仅适用于 UML 1.3。在NetBeans的元数据存储库(MDR)的读出手柄UML 1.4和UML 1.5。它可以用作独立库(这是 ArgoUML 使用的),因此您不需要 NetBeans。对于 UML 2.x,我认为 Eclipse EMF 和 UML2 库是您唯一的选择。EMF 是一个依赖项,但它确实是您想要的 UML2 东西。与 MDR 和 NetBeans 一样,您不需要 Eclipse。ArgoUML 使用 Eclipse 库来支持其 UML 2.x。

回答by Stephen C

In order to read XMI/UML using EMF, you will need to find, generate or write ECore model for UML. Once you have one of those, you can generate the in-memory classes for manipulating the UML and leverage the other EMF infrastructure.

为了使用 EMF 读取 XMI/UML,您需要为 UML 查找、生成或编写 ECore 模型。一旦您拥有其中之一,您就可以生成内存中的类来操作 UML 并利用其他 EMF 基础设施。

But a simpler route may be to use the UML2 infrastructure developed by the Eclipse MDT project. (My guess is that it uses EMF under the hood and that there is an ECore model for UML2 in there somewhere.)

但更简单的方法可能是使用 Eclipse MDT 项目开发的 UML2 基础结构。(我的猜测是它在引擎盖下使用 EMF,并且在某处有一个用于 UML2 的 ECore 模型。)

回答by marklai

ArgoUMLcan import XMI to its UML model and generate code for Java, C++, C#, PHP4 and PHP5.

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

回答by Kissaki

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.

您正在寻找的是JMI(“Java 元数据接口”)的Java 规范,它实现了用于描述元数据的 MOF 和用于传输元数据的 XMI。

Unfortunately I am currently looking for implementations of JMI myself and suns JMI page seems to be a bit outdated. The open source implementation by netbeans seems to have been dropped for version 6.

不幸的是,我目前正在自己​​寻找 JMI 的实现,而 suns JMI 页面似乎有点过时了。netbeans 的开源实现似乎已在第 6 版中删除。