How to parse XMI Files containing SysML Models in Python?

859 views
Skip to first unread message

mps...@gmail.com

unread,
Apr 28, 2015, 9:14:04 AM4/28/15
to sysml...@googlegroups.com
Hello

Once you have finished a SysML model you can export your model as a XMI file. But how I can parse thru that XMI file using python? At the end I want to get a list with all objects used in the model. For example:

TestModel
- Block Definiation Diagramm
- - Block Car
- - - description
- - - id
- - Block Engine
- - - horsepower
- another diagramm ....
- - another object used in this diagram

I spent almost about 40 hours to find a way...its to despair

I am thankful for any helpful information I will get.

Cheers,
Michael

JP

unread,
Apr 29, 2015, 5:00:24 PM4/29/15
to sysml...@googlegroups.com
I think it depends on the tool you're using, as they all seem to generate different syntax for their XMI outputs.

The best advice I could give is to make a model with whatever elements you want to look at, export that model as an XMI file, then look at the XMI file and how the tool output said elements to get a sense for how you should parse it.

david reye

unread,
Apr 29, 2015, 11:52:23 PM4/29/15
to sysml...@googlegroups.com

Going to the XMI should be a last resort. It is not standardised across tools, there are multiple versions of XMI to be aware of and you need a very good understanding of the underlying metamodel.
I would try one of the following first:
look at the built-in reporting features offered by your modelling tool,
look at the tool's public APIs and write a client which pulls out the data you need

In my experience, the reporting tools themselves can be frustrating. The API route may be simpler and give you more control.

Cheers,
David


-- 
-- 
You received this message because you are subscribed to the Google
Groups "SysML Forum" group.
Public website: http://www.SysMLforum.com
To post to this group, send email to sysml...@googlegroups.com
To unsubscribe from this group, send email to
sysmlforum+...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/sysmlforum?hl=en_US?hl=en
--- 
You received this message because you are subscribed to the Google Groups "SysML Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sysmlforum+...@googlegroups.com.
To post to this group, send email to sysml...@googlegroups.com.
Visit this group at http://groups.google.com/group/sysmlforum.
To view this discussion on the web visit https://groups.google.com/d/msgid/sysmlforum/59742702-caf7-4429-a6dc-a52342192224%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

David Reye
Software Systems Consultant




JP

unread,
Apr 30, 2015, 2:17:53 PM4/30/15
to sysml...@googlegroups.com
Yeah, what David said is a much better approach to what you seem to be trying to get as opposed to messing with the XMI outputs. Out of curiosity, what tool are you using?

On Tuesday, April 28, 2015 at 8:14:04 AM UTC-5, mps...@gmail.com wrote:

mps...@gmail.com

unread,
May 6, 2015, 4:04:33 AM5/6/15
to sysml...@googlegroups.com
 Thank you both four your Help.

I am using Visual Paradigm, Altova UModel and NoMagic Cameo :-)

It is my task (within my internship) finding a way to parse thru XMI files. So I think i have to do it with the XMI file and can not use the tools API.
Reply all
Reply to author
Forward
0 new messages