Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Parsing a model (xmi) to get tree view?(How to parse an xmi model to get tree view?)
icon5.gif  Parsing a model (xmi) to get tree view? [message #675190] Mon, 30 May 2011 14:30 Go to next message
Renaud C is currently offline Renaud CFriend
Messages: 19
Registered: May 2011
Junior Member
Hello everyone,
I began to work on an EMF project just few days ago, and I encounter some problems.

Here is my situation: I have a simple input file example.model conforms to a MetaModel:

<?xml version="1.0" encoding="ASCII"?>
<CollegeMMDiff:DifferenceModel xmi:version="2.0" xmlns:xmi=".../XMI" xmlns:xsi=".../XMLSchema-instance" xmlns:CollegeMMDiff=".../org.openembedd.CollegeMMDiff" xmi:id="_nBd54IemEeCwk8SZVLPN7A">
  <differenceElements xsi:type="CollegeMMDiff:ChangedCollege" xmi:id="_ojXxgIemEeCwk8SZVLPN7A">
    <classrooms xsi:type="CollegeMMDiff:ChangedClassRoom" xmi:id="_q5IH8IemEeCwk8SZVLPN7A" location="U2-036" updatedElement="_r04lkIemEeCwk8SZVLPN7A"/>
    <lessons xsi:type="CollegeMMDiff:ChangedLesson" xmi:id="_zE6doIemEeCwk8SZVLPN7A" classroom="_q5IH8IemEeCwk8SZVLPN7A"/>
  </differenceElements>
  <differenceElements xsi:type="CollegeMMDiff:College" xmi:id="_pTDiAIemEeCwk8SZVLPN7A">
    <classrooms xmi:id="_r04lkIemEeCwk8SZVLPN7A" location="U2-039"/>
    <lessons xmi:id="_zwkpwIemEeCwk8SZVLPN7A" students="_yEilwIemEeCwk8SZVLPN7A" classroom="_r04lkIemEeCwk8SZVLPN7A"/>
  </differenceElements>
  <differenceElements xsi:type="CollegeMMDiff:DeletedMatter" xmi:id="_wKWJ8IemEeCwk8SZVLPN7A" title="Math"/>
  <differenceElements xsi:type="CollegeMMDiff:AddedMatter" xmi:id="_xIMSQIemEeCwk8SZVLPN7A" title="Italian"/>
  <differenceElements xsi:type="CollegeMMDiff:AddedStudent" xmi:id="_yEilwIemEeCwk8SZVLPN7A" name="John"/>
</CollegeMMDiff:DifferenceModel>


And I want to display this model in a tree structure (in an Eclipse view previously created).
But I really don't know how to proceed, what I have to use (EMF API?)...

Does someone could enlighten me on this?

Thank you very much!
Re: Parsing a model (xmi) to get tree view? [message #675799 is a reply to message #675190] Wed, 01 June 2011 14:48 Go to previous messageGo to next message
saurav sarkar is currently offline saurav sarkarFriend
Messages: 428
Registered: July 2009
Senior Member
Hi Ren,

You can always your model in the sample ecore reflective editor which gives you a tree view
of your model.

cheers,
Saurav


Re: Parsing a model (xmi) to get tree view? [message #675980 is a reply to message #675799] Thu, 02 June 2011 09:09 Go to previous messageGo to next message
Renaud C is currently offline Renaud CFriend
Messages: 19
Registered: May 2011
Junior Member
Thanks!
Ok, maybe I'm wrong, but the different elements are not ecore elements but elements conforms to a metamodel previously defined, so an ecore parsing can't give me the structure of this .model file, wihtout considering the metamodel, isn't it?
Re: Parsing a model (xmi) to get tree view? [message #677346 is a reply to message #675980] Wed, 08 June 2011 09:01 Go to previous message
Renaud C is currently offline Renaud CFriend
Messages: 19
Registered: May 2011
Junior Member
Is someone can tell me how to parse my model with the EMF API?
Thanks!
(no subject) [message #687100 is a reply to message #675190] Mon, 30 May 2011 14:35 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi ?

Interactively, Open With Sample Reflective Ecore Editor.

Programmatically, reuse the TreeViewer code from the Same Ecore Editor.

Regards

Ed Willink

On 30/05/2011 15:30, forums-noreply@eclipse.org wrote:
> Hello everyone,
> I began to work on an EMF project just few days ago, and I encounter
> some problems.
>
> Here is my situation: I have a simple input file example.model
> conforms to a MetaModel:
>
> <?xml version="1.0" encoding="ASCII"?>
> <CollegeMMDiff:DifferenceModel xmi:version="2.0" xmlns:xmi=".../XMI"
> xmlns:xsi=".../XMLSchema-instance"
> xmlns:CollegeMMDiff=".../org.openembedd.CollegeMMDiff"
> xmi:id="_nBd54IemEeCwk8SZVLPN7A">
> <differenceElements xsi:type="CollegeMMDiff:ChangedCollege"
> xmi:id="_ojXxgIemEeCwk8SZVLPN7A">
> <classrooms xsi:type="CollegeMMDiff:ChangedClassRoom"
> xmi:id="_q5IH8IemEeCwk8SZVLPN7A" location="U2-036"
> updatedElement="_r04lkIemEeCwk8SZVLPN7A"/>
> <lessons xsi:type="CollegeMMDiff:ChangedLesson"
> xmi:id="_zE6doIemEeCwk8SZVLPN7A" classroom="_q5IH8IemEeCwk8SZVLPN7A"/>
> </differenceElements>
> <differenceElements xsi:type="CollegeMMDiff:College"
> xmi:id="_pTDiAIemEeCwk8SZVLPN7A">
> <classrooms xmi:id="_r04lkIemEeCwk8SZVLPN7A" location="U2-039"/>
> <lessons xmi:id="_zwkpwIemEeCwk8SZVLPN7A"
> students="_yEilwIemEeCwk8SZVLPN7A" classroom="_r04lkIemEeCwk8SZVLPN7A"/>
> </differenceElements>
> <differenceElements xsi:type="CollegeMMDiff:DeletedMatter"
> xmi:id="_wKWJ8IemEeCwk8SZVLPN7A" title="Math"/>
> <differenceElements xsi:type="CollegeMMDiff:AddedMatter"
> xmi:id="_xIMSQIemEeCwk8SZVLPN7A" title="Italian"/>
> <differenceElements xsi:type="CollegeMMDiff:AddedStudent"
> xmi:id="_yEilwIemEeCwk8SZVLPN7A" name="John"/>
> </CollegeMMDiff:DifferenceModel>
>
> And I want to display this model in a tree structure (in an Eclipse
> view previously created).
> But I really don't know how to proceed, what I have to use (EMF API?)...
>
> Does someone could enlighten me on this?
>
> Thank you very much!
>
(no subject) [message #687131 is a reply to message #675980] Thu, 02 June 2011 14:14 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
Renaud,

In all cases, you must have an Ecore model to parse an *.xmi file. It
might just be a dynamic Ecore model you read from a *.ecore file, but
you definitely need to know the model.


Renaud C wrote:
> Thanks!
> Ok, maybe I'm wrong, but the different elements are not ecore elements
> but elements conforms to a metamodel previously defined, so an ecore
> parsing can't give me the structure of this .model file, wihtout
> considering the metamodel, isn't it?


Ed Merks
Professional Support: https://www.macromodeling.com/
(no subject) [message #687368 is a reply to message #675980] Thu, 02 June 2011 14:14 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
Renaud,

In all cases, you must have an Ecore model to parse an *.xmi file. It
might just be a dynamic Ecore model you read from a *.ecore file, but
you definitely need to know the model.


Renaud C wrote:
> Thanks!
> Ok, maybe I'm wrong, but the different elements are not ecore elements
> but elements conforms to a metamodel previously defined, so an ecore
> parsing can't give me the structure of this .model file, wihtout
> considering the metamodel, isn't it?


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Re: [Teneo] Need ClassMetadata but it's not present
Next Topic:(no subject)
Goto Forum:
  


Current Time: Thu Mar 28 18:19:47 GMT 2024

Powered by FUDForum. Page generated in 0.02626 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top