Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Creating a model-instance from .xml-file
Creating a model-instance from .xml-file [message #1037151] Tue, 09 April 2013 08:15 Go to next message
Wazza Daya is currently offline Wazza DayaFriend
Messages: 5
Registered: April 2013
Junior Member
Hi!

First of all, i am sorry if this is the wrong forum. I am new here, and there really are a lot Smile

I have been working with Eclipse Modelling Tools for a few months now, so i know the basics of it.

My problem is as follows:
I have an ecore model and i now i want to be able to create a model (instance, i guess?) from an XML-file (or XMI?). In the end i want to transform this model to an AST model, but that is not the topic of this post. Also i would like for all this to be done automatically (programmatically), but first of all i just want to be able to do it manually in Eclipse to understand the process.

I have read several articles about this topic, but it has not really got me going. I suppose, that i will have to generate some schema (XSD?) and then somehow load an XML-file, that corresponds to the schema?

I hope that someone is able to get me started on this.

Thanks in advance!
Re: Creating a model-instance from .xml-file [message #1037992 is a reply to message #1037151] Wed, 10 April 2013 09:04 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33108
Registered: July 2009
Senior Member
Hasse,

Comments below.

On 09/04/2013 3:05 PM, Hasse Ravn wrote:
> Hi!
>
> First of all, i am sorry if this is the wrong forum. I am new here,
> and there really are a lot :)
>
> I have been working with Eclipse Modelling Tools for a few months now,
> so i know the basics of it.
>
> My problem is as follows:
> I have an ecore model and i now i want to be able to create a model
> (instance, i guess?) from an XML-file (or XMI?). In the end i want to
> transform this model to an AST model, but that is not the topic of
> this post. Also i would like for all this to be done automatically
> (programmatically), but first of all i just want to be able to do it
> manually in Eclipse to understand the process.
>
> I have read several articles about this topic, but it has not really
> got me going.
What specifically have you looked at?
> I suppose, that i will have to generate some schema (XSD?)
Have you looked at the tutorial for generating a modeling from an XML
Schema?
> and then somehow load an XML-file, that corresponds to the schema?
>
> I hope that someone is able to get me started on this.
>
> Thanks in advance!


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Creating a model-instance from .xml-file [message #1041030 is a reply to message #1037992] Sun, 14 April 2013 14:05 Go to previous messageGo to next message
Wazza Daya is currently offline Wazza DayaFriend
Messages: 5
Registered: April 2013
Junior Member
Hi!

Thank you for your answer.

I have searched for what you suggested and looked a little more around. What i want is to be able to create an instance of my meta-model from by loading/reading an .xmi (or .xml)-file. It seems that what i am looking for is the mwe2 workflow, which should somehow make me able to do the aforementioned?
Re: Creating a model-instance from .xml-file [message #1041429 is a reply to message #1041030] Mon, 15 April 2013 05:02 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33108
Registered: July 2009
Senior Member
Hasse,

Comments below.

On 14/04/2013 4:05 PM, Hasse Ravn wrote:
> Hi!
>
> Thank you for your answer.
>
> I have searched for what you suggested and looked a little more
> around. What i want is to be able to create an instance of my
> meta-model from by loading/reading an .xmi (or .xml)-file.
That's exactly what the generated editor does, right?
> It seems that what i am looking for is the mwe2 workflow, which should
> somehow make me able to do the aforementioned?
How is what the generated editor does different from what you want to do?


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Creating a model-instance from .xml-file [message #1041738 is a reply to message #1041429] Mon, 15 April 2013 13:44 Go to previous messageGo to next message
Wazza Daya is currently offline Wazza DayaFriend
Messages: 5
Registered: April 2013
Junior Member
Hi,

When i started the thread, i had not looked into the mwe2.

What i wanted now, was just a confirmation, that i was going in the right direction.

So to follow up; I used the Reader and Writer of the mwe2 to read a dynamic instance (.xmi) and then it creates an .xmi file with the meta-model schema (i think). But what i want is for it to create an .xmi file of an instance - in this case it would just be a copy of the input, but after seeing it work i would then input a less "correct" .xmi/.xml file (i suppose this might demand some changes to my reader?), which would get me to the goal i am aiming at.

This might be where the Generator of mwe2 comes in (creating an instance instead of the meta-model)?
Re: Creating a model-instance from .xml-file [message #1041750 is a reply to message #1041738] Mon, 15 April 2013 14:07 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33108
Registered: July 2009
Senior Member
Hasse,

I must say I really have no clue what you're hoping to accomplish. It's
all just a bit too abstract to be sure I know what you're talking
about. MWE is just there to automate a bunch of processing steps. It's
just not concrete to me what all those steps are supposed to do.


On 15/04/2013 3:44 PM, Hasse Ravn wrote:
> Hi,
>
> When i started the thread, i had not looked into the mwe2.
>
> What i wanted now, was just a confirmation, that i was going in the
> right direction.
>
> So to follow up; I used the Reader and Writer of the mwe2 to read a
> dynamic instance (.xmi) and then it creates an .xmi file with the
> meta-model schema (i think). But what i want is for it to create an
> .xmi file of an instance - in this case it would just be a copy of the
> input, but after seeing it work i would then input a less "correct"
> .xmi/.xml file (i suppose this might demand some changes to my
> reader?), which would get me to the goal i am aiming at.
>
> This might be where the Generator of mwe2 comes in (creating an
> instance instead of the meta-model)?


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Creating a model-instance from .xml-file [message #1041802 is a reply to message #1041750] Mon, 15 April 2013 15:48 Go to previous messageGo to next message
Wazza Daya is currently offline Wazza DayaFriend
Messages: 5
Registered: April 2013
Junior Member
Hi,

I'm very confused myself, so no wonder you're getting confused Smile

What i want to be able to, is to generate instances of a java class (instances of the meta-model) in java code. I hope that makes sense.

So i want to provide an .xml file with something like <myClass att1="val1" att2="val2" />, and then the mwe2 should generate the java code myClass myclass1 = new myClass(val1, val2); or something like that. I really hope it makes more sense now.
Re: Creating a model-instance from .xml-file [message #1041882 is a reply to message #1041802] Mon, 15 April 2013 17:56 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33108
Registered: July 2009
Senior Member
Hasse,

Comments below.

On 15/04/2013 5:48 PM, Hasse Ravn wrote:
> Hi,
>
> I'm very confused myself, so no wonder you're getting confused :)
>
> What i want to be able to, is to generate instances of a java class
> (instances of the meta-model) in java code. I hope that makes sense.
No, I don't know what generate instances of a Java class means.
>
> So i want to provide an .xml file with something like <myClass
> att1="val1" att2="val2" />, and then the mwe2 should generate the java
> code myClass myclass1 = new myClass(val1, val2); or something like
> that. I really hope it makes more sense now.
I really don't see the point. Again, if you have a schema for this
XML, you can generate a Java API from that schema so you can do
something like MyFactory.eINSTANCE.createMyClass() and then call methods
like setAtt1("val1"). How about you follow one of the tutorials
completely to the end, i.e., one involving your schema...


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Creating a model-instance from .xml-file [message #1043873 is a reply to message #1041882] Thu, 18 April 2013 08:07 Go to previous message
Wazza Daya is currently offline Wazza DayaFriend
Messages: 5
Registered: April 2013
Junior Member
Okay, i will keep on searching then. Thanks for taking your time!
Previous Topic:[CDO] Error when deleting a resource from the root
Next Topic:FSM/CPN pros and cons
Goto Forum:
  


Current Time: Tue Mar 19 11:11:28 GMT 2024

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

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

Back to the top