Creating a model-instance from .xml-file [message #1037151] |
Tue, 09 April 2013 08:15 |
Wazza Daya 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
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 |
Ed Merks 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 #1041882 is a reply to message #1041802] |
Mon, 15 April 2013 17:56 |
Ed Merks 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/
|
|
|
|
Powered by
FUDForum. Page generated in 0.03457 seconds