开发者

convert an xmi file to xml file using python

开发者 https://www.devze.com 2023-03-09 22:16 出处:网络
I need to convert an activity diagram in xmi format t开发者_Go百科o xml format.Is this conversion possible using python?Are there any tools to convert xmi files to xml?Converting XML to XML is usually

I need to convert an activity diagram in xmi format t开发者_Go百科o xml format.Is this conversion possible using python?Are there any tools to convert xmi files to xml?


Converting XML to XML is usually called XML transformation. For Python you can use libxsltmod to perform XML transformations by using XSLT 'stylesheets'.


As Ignacio says, the problem may not be that the target tool expects XML but that probably expects a diffent XMI format.

Unfortunately, each tool follows its own interpretation of the XMI standard so two modeling tools will most likely generate two incompatible XMI files for the same model. See an example in this "model once open anywhere not true" post


you can get the information that you need (classes and attribute ...) from any file.xmi this doc maybe help

from xml.dom import minidom
xmldoc = minidom.parse('file.xmi')
        for element in xmldoc.getElementsByTagName("UML:Class"):
                print(" -> UML:Class ",element.getAttribute('name'))
                for a in element.getElementsByTagName("UML:Attribute"):
                        print("   -> UML:Attr : ",a.getAttribute('name'))
0

精彩评论

暂无评论...
验证码 换一张
取 消