Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » XMI to java objects
XMI to java objects [message #878067] Mon, 28 May 2012 13:00 Go to next message
Kosala Yapa is currently offline Kosala YapaFriend
Messages: 159
Registered: September 2010
Senior Member
Hi there,

How to create java objects from an XMI file(target.xmi)?

option 1: I know, it must be possible reading through an XML parser. // I do not like this approach, it is a lot of coding.

option 2: I know, eclipse EMF provides EMF generator model. I could manage to take Generate Model Code from the .ecore model related to this XMI file (target.ecore). The generated code consist of model, model.impl and model.util. Now, Is it possible to use these coding to read XMI file to generate java objects? How to do that?


I am trying to create java objects from the following XMI file(target.xmi).

<?xml version="1.0" encoding="ISO-8859-1"?>

<target:Device xmi:version="2.0" xmlns:xmi="...//www.omg.org/XMI" xmlns:xsi="...//www.w3.org/2001/XMLSchema-instance"
xmlns:target="target"
name="PSSuniversal22222"
s7DeviceReference="{7F6AC5F1-E8E0-49E5-ABA1-26E4A6A74175}{001417C3-00000003-001417B3-00000002-00112001-00000107}{SD_example1}">

<Module name="PSSuES4DO0.5_1"
deviceID="0x00000C00"
s7ModuleReference="CFAF3ED5-37E4-476B-AE64-94FDD6429D1E}{001417C5-00000009-001417C3-00000003-00112001-00000107"
isSelectedWithinStep7="false"/>

<Module name="PSSuniversal33333"
deviceID="0x00000229"
s7ModuleReference="CFAF3ED5-37E4-476B-AE64-94FDD6429D1E}{001417C5-00000009-001417C3-00000003-00112001-00000108"
isSelectedWithinStep7="false"/>

<HeadModule xsi:type="target:Module"
name="PSSu E F PS (PROFIsafe)"
deviceID="0x00000801"
s7ModuleReference="{9A856DAC-1D0A-46F7-B69F-40E2DC6511DD}{001417C5-0000002F-001417C3-0000002A-00112001-00000107}{SD_example1}"
isSelectedWithinStep7="false"/>

</target:Device>


Thanks in advance.
Kosala
Re: XMI to java objects [message #878080 is a reply to message #878067] Mon, 28 May 2012 13:35 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33133
Registered: July 2009
Senior Member
Kosala,

Trying invoking Generate Test Code and look at the generated XyzExample
in the *.tests project.

On 28/05/2012 3:00 PM, Kosala Yapa wrote:
> Hi there,
>
> How to create java objects from an XMI file(target.xmi)?
> option 1: I know, it must be possible reading through an XML parser.
> // I do not like this approach, it is a lot of coding.
>
> option 2: I know, eclipse EMF provides EMF generator model. I could
> manage to take Generate Model Code from the .ecore model related to
> this XMI file (target.ecore). The generated code consist of model,
> model.impl and model.util. Now, Is it possible to use these coding to
> read XMI file to generate java objects? How to do that?
>
>
> I am trying to create java objects from the following XMI
> file(target.xmi).
>
> <?xml version="1.0" encoding="ISO-8859-1"?>
>
> <target:Device xmi:version="2.0" xmlns:xmi="...//www.omg.org/XMI"
> xmlns:xsi="...//www.w3.org/2001/XMLSchema-instance"
> xmlns:target="target" name="PSSuniversal22222"
> s7DeviceReference="{7F6AC5F1-E8E0-49E5-ABA1-26E4A6A74175}{001417C3-00000003-001417B3-00000002-00112001-00000107}{SD_example1}">
>
> <Module name="PSSuES4DO0.5_1" deviceID="0x00000C00"
>
> s7ModuleReference="CFAF3ED5-37E4-476B-AE64-94FDD6429D1E}{001417C5-00000009-001417C3-00000003-00112001-00000107"
> isSelectedWithinStep7="false"/>
>
> <Module name="PSSuniversal33333" deviceID="0x00000229"
>
> s7ModuleReference="CFAF3ED5-37E4-476B-AE64-94FDD6429D1E}{001417C5-00000009-001417C3-00000003-00112001-00000108"
> isSelectedWithinStep7="false"/>
>
> <HeadModule xsi:type="target:Module" name="PSSu E F PS
> (PROFIsafe)" deviceID="0x00000801"
> s7ModuleReference="{9A856DAC-1D0A-46F7-B69F-40E2DC6511DD}{001417C5-0000002F-001417C3-0000002A-00112001-00000107}{SD_example1}"
> isSelectedWithinStep7="false"/>
>
> </target:Device>
>
>
> Thanks in advance.
> Kosala


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: XMI to java objects [message #878086 is a reply to message #878080] Mon, 28 May 2012 13:49 Go to previous messageGo to next message
Kosala Yapa is currently offline Kosala YapaFriend
Messages: 159
Registered: September 2010
Senior Member
Hi Merks,

I right clicked on the package Target and run Generate Test Code, but I cannot find where this XyZExample is created. It looks like something is hapenning without errors. I cannot find any *.tests project. Do you have any clue, where this project is created?

Thanks
Kosala
Re: XMI to java objects [message #878092 is a reply to message #878086] Mon, 28 May 2012 14:12 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33133
Registered: July 2009
Senior Member
Kosala,

Click on the root, i.e., GenModel. Of course the Xyz in XyzExample
depends on the name of your model as does the * in the *.tests project.


On 28/05/2012 3:49 PM, Kosala Yapa wrote:
> Hi Merks,
>
> I right clicked on the package Target and run Generate Test Code, but
> I cannot find where this XyZExample is created. It looks like
> something is hapenning without errors. I cannot find any *.tests
> project. Do you have any clue, where this project is created?
>
> Thanks
> Kosala


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: XMI to java objects [message #878103 is a reply to message #878092] Mon, 28 May 2012 14:53 Go to previous messageGo to next message
Kosala Yapa is currently offline Kosala YapaFriend
Messages: 159
Registered: September 2010
Senior Member
Merks,
Thanks. Do you think, should I use Generate Edit and Generate Editor before Generate Test Code? They looks necessary for Generate Test Code.
Re: XMI to java objects [message #878177 is a reply to message #878103] Mon, 28 May 2012 18:47 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33133
Registered: July 2009
Senior Member
No, the tests depend only on the model (as you'll see in the
dependencies in the MANIFEST.MF).

On 28/05/2012 4:53 PM, Kosala Yapa wrote:
> Merks,
> Thanks. Do you think, should I use Generate Edit and Generate Editor
> before Generate Test Code? They looks necessary for Generate Test Code.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: XMI to java objects [message #878390 is a reply to message #878177] Tue, 29 May 2012 08:03 Go to previous messageGo to next message
Kosala Yapa is currently offline Kosala YapaFriend
Messages: 159
Registered: September 2010
Senior Member
Hi Merks,

I could manage to get the tests from Generate Test Code.

My xyz.xmi file is located in C:\...\abc.model

How can i read it from XYZExample.java?

I just tried the following, but does not work yet.

Resource resource = resourceSet.createResource(URI.createURI("C:/.../abc.model/xyz.xmi"));

Any help is appriciated.

Thanks.
Kosala
Re: XMI to java objects [message #878424 is a reply to message #878390] Tue, 29 May 2012 09:25 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33133
Registered: July 2009
Senior Member
Kosala,

Please look closely at how the generated example handles the args from main.

On 29/05/2012 10:03 AM, Kosala Yapa wrote:
> Hi Merks,
>
> I could manage to get the tests from Generate Test Code.
>
> My xyz.xmi file is located in C:\...\abc.model
>
> How can i read it from XYZExample.java?
>
> I just tried the following, but does not work yet.
>
> Resource resource =
> resourceSet.createResource(URI.createURI("C:/.../abc.model/xyz.xmi"));
>
> Any help is appriciated.
>
> Thanks.
> Kosala


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: XMI to java objects [message #878562 is a reply to message #878424] Tue, 29 May 2012 14:25 Go to previous messageGo to next message
Kosala Yapa is currently offline Kosala YapaFriend
Messages: 159
Registered: September 2010
Senior Member
Hi there,

I am not passing any parameter to main().

that is
----
if (args.length == 0) {
System.out.println("Enter a list of file paths or URIs that have content like this:");
try {
Resource resource = resourceSet.createResource(URI.createURI("C:/.../abc.model/xyz.xmi"));
Device root = TargetFactory.eINSTANCE.createDevice();
resource.getContents().add(root);
resource.save(System.out, null);
}
catch (IOException exception) {
exception.printStackTrace();
}
}

------

but it does not read the xmi file.


Re: XMI to java objects [message #878582 is a reply to message #878562] Tue, 29 May 2012 15:01 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33133
Registered: July 2009
Senior Member
Have you looked at the code that handles the arguments in the case that
there actually are arguments?

On 29/05/2012 4:25 PM, Kosala Yapa wrote:
> Hi there,
>
> I am not passing any parameter to main().
>
> that is ----
> if (args.length == 0) {
> System.out.println("Enter a list of file paths or URIs
> that have content like this:");
> try {
> Resource resource =
> resourceSet.createResource(URI.createURI("C:/.../abc.model/xyz.xmi"));
> Device root = TargetFactory.eINSTANCE.createDevice();
> resource.getContents().add(root);
> resource.save(System.out, null);
> }
> catch (IOException exception) {
> exception.printStackTrace();
> }
> }
>
> ------
>
> but it does not read the xmi file.
>
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: XMI to java objects [message #878928 is a reply to message #878582] Wed, 30 May 2012 08:17 Go to previous messageGo to next message
Kosala Yapa is currently offline Kosala YapaFriend
Messages: 159
Registered: September 2010
Senior Member
Hi Merks,

Thanks. You are right.

Now I can see the root element as:
target.impl.DeviceImpl@18ba593 (name: null, s7DeviceReference: null)

but still null values for attributes?


"target" is the package name. target.ecore is

<?xml version="1.0" encoding="UTF-8"?>
<ecore:EPackage xmi:version="2.0"
xmlns:xmi=".../XMI" xmlns:xsi=".../2001/XMLSchema-instance"
xmlns:ecore=".../emf/2002/Ecore" name="target"
>

<eClassifiers xsi:type="ecore:EClass" name="Device">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType .../emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="s7DeviceReference" eType="ecore:EDataType .../emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="Module" upperBound="-1"
eType="#//Module" containment="true"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="HeadModule" lowerBound="1"
eType="#//HeadModule" containment="true"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Module">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType .../emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="deviceID" eType="ecore:EDataType.../emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="partNumber" eType="ecore:EDataType .../emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="width" eType="ecore:EDataType .../emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="baseModule" eType="ecore:EDataType .../emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="slotWidth" eType="ecore:EDataType .../emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="s7ModuleReference" eType="ecore:EDataType .../emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="isSelectedWithinStep7"
eType="ecore:EDataType .../emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="config" eType="ecore:EDataType .../emf/2002/Ecore#//EString"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="HeadModule" eSuperTypes="#//Module">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="hType" eType="ecore:EDataType .../emf/2002/Ecore#//EString"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Project">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType .../emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="comment" eType="ecore:EDataType .../emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="author" eType="ecore:EDataType .../emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="projectCRC" eType="ecore:EDataType .../emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="step7CRC" eType="ecore:EDataType .../emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="Device" upperBound="-1"
eType="#//Device" containment="true"/>
</eClassifiers>
</ecore:EPackage>






my xmi file is:
<?xml version="1.0" encoding="ISO-8859-1"?>
<Device xmi:version="2.0" xmlns:xmi=".../XMI" xmlns:xsi=".../2001/XMLSchema-instance" xmlns="" name="PSSuniversal22222" s7DeviceReference="{7F6AC5F1-E8E0-49E5-ABA1-26E4A6A74175}{001417C3-00000003-001417B3-00000002-00112001-00000107}{SD_example1}">
<Module name="PSSuES4DO0.5_1" deviceID="0x00000C00" s7ModuleReference="CFAF3ED5-37E4-476B-AE64-94FDD6429D1E}{001417C5-00000009-001417C3-00000003-00112001-00000107" isSelectedWithinStep7="false"/>
<Module name="PSSuniversal33333" deviceID="0x00000229" s7ModuleReference="CFAF3ED5-37E4-476B-AE64-94FDD6429D1E}{001417C5-00000009-001417C3-00000003-00112001-00000108" isSelectedWithinStep7="false"/>
<HeadModule xsi:type="Module" name="PSSu E F PS (PROFIsafe)" deviceID="0x00000801" s7ModuleReference="{9A856DAC-1D0A-46F7-B69F-40E2DC6511DD}{001417C5-0000002F-001417C3-0000002A-00112001-00000107}{SD_example1}" isSelectedWithinStep7="false"/>
</Device>

Thanks
K
Re: XMI to java objects [message #878937 is a reply to message #878928] Wed, 30 May 2012 08:32 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33133
Registered: July 2009
Senior Member
Kosala,

Your XMI looks quite odd. Doesn't your EPackage have a proper nsURI?
I'd expect the root element of your XMI to be qualified...


On 30/05/2012 10:18 AM, Kosala Yapa wrote:
> Hi Merks,
>
> Thanks. You are right.
> Now I can see the root element as:
> mailto:target.impl.DeviceImpl@18ba593 (name: null, s7DeviceReference:
> null)
>
> but still null values for attributes?
>
>
> "target" is the package name. target.ecore is
>
> <?xml version="1.0" encoding="UTF-8"?>
> <ecore:EPackage xmi:version="2.0"
> xmlns:xmi=".../XMI" xmlns:xsi=".../2001/XMLSchema-instance"
> xmlns:ecore=".../emf/2002/Ecore" name="target"
>>
> <eClassifiers xsi:type="ecore:EClass" name="Device">
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
> eType="ecore:EDataType .../emf/2002/Ecore#//EString"/>
> <eStructuralFeatures xsi:type="ecore:EAttribute"
> name="s7DeviceReference" eType="ecore:EDataType
> .../emf/2002/Ecore#//EString"/>
> <eStructuralFeatures xsi:type="ecore:EReference" name="Module"
> upperBound="-1"
> eType="#//Module" containment="true"/>
> <eStructuralFeatures xsi:type="ecore:EReference" name="HeadModule"
> lowerBound="1"
> eType="#//HeadModule" containment="true"/>
> </eClassifiers>
> <eClassifiers xsi:type="ecore:EClass" name="Module">
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
> eType="ecore:EDataType .../emf/2002/Ecore#//EString"/>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="deviceID"
> eType="ecore:EDataType.../emf/2002/Ecore#//EString"/>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="partNumber"
> eType="ecore:EDataType .../emf/2002/Ecore#//EString"/>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="width"
> eType="ecore:EDataType .../emf/2002/Ecore#//EString"/>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="baseModule"
> eType="ecore:EDataType .../emf/2002/Ecore#//EString"/>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="slotWidth"
> eType="ecore:EDataType .../emf/2002/Ecore#//EString"/>
> <eStructuralFeatures xsi:type="ecore:EAttribute"
> name="s7ModuleReference" eType="ecore:EDataType
> .../emf/2002/Ecore#//EString"/>
> <eStructuralFeatures xsi:type="ecore:EAttribute"
> name="isSelectedWithinStep7"
> eType="ecore:EDataType .../emf/2002/Ecore#//EString"/>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="config"
> eType="ecore:EDataType .../emf/2002/Ecore#//EString"/>
> </eClassifiers>
> <eClassifiers xsi:type="ecore:EClass" name="HeadModule"
> eSuperTypes="#//Module">
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="hType"
> eType="ecore:EDataType .../emf/2002/Ecore#//EString"/>
> </eClassifiers>
> <eClassifiers xsi:type="ecore:EClass" name="Project">
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
> eType="ecore:EDataType .../emf/2002/Ecore#//EString"/>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="comment"
> eType="ecore:EDataType .../emf/2002/Ecore#//EString"/>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="author"
> eType="ecore:EDataType .../emf/2002/Ecore#//EString"/>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="projectCRC"
> eType="ecore:EDataType .../emf/2002/Ecore#//EString"/>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="step7CRC"
> eType="ecore:EDataType .../emf/2002/Ecore#//EString"/>
> <eStructuralFeatures xsi:type="ecore:EReference" name="Device"
> upperBound="-1"
> eType="#//Device" containment="true"/>
> </eClassifiers>
> </ecore:EPackage>
>
>
>
>
>
>
> my xmi file is:
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <Device xmi:version="2.0" xmlns:xmi=".../XMI"
> xmlns:xsi=".../2001/XMLSchema-instance" xmlns=""
> name="PSSuniversal22222"
> s7DeviceReference="{7F6AC5F1-E8E0-49E5-ABA1-26E4A6A74175}{001417C3-00000003-001417B3-00000002-00112001-00000107}{SD_example1}">
> <Module name="PSSuES4DO0.5_1" deviceID="0x00000C00"
> s7ModuleReference="CFAF3ED5-37E4-476B-AE64-94FDD6429D1E}{001417C5-00000009-001417C3-00000003-00112001-00000107"
> isSelectedWithinStep7="false"/>
> <Module name="PSSuniversal33333" deviceID="0x00000229"
> s7ModuleReference="CFAF3ED5-37E4-476B-AE64-94FDD6429D1E}{001417C5-00000009-001417C3-00000003-00112001-00000108"
> isSelectedWithinStep7="false"/>
> <HeadModule xsi:type="Module" name="PSSu E F PS (PROFIsafe)"
> deviceID="0x00000801"
> s7ModuleReference="{9A856DAC-1D0A-46F7-B69F-40E2DC6511DD}{001417C5-0000002F-001417C3-0000002A-00112001-00000107}{SD_example1}"
> isSelectedWithinStep7="false"/>
> </Device>
>
> Thanks K
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: XMI to java objects [message #878953 is a reply to message #878937] Wed, 30 May 2012 09:06 Go to previous messageGo to next message
Kosala Yapa is currently offline Kosala YapaFriend
Messages: 159
Registered: September 2010
Senior Member
EPackage:

<ecore:EPackage xmi:version="2.0"
xmlns:xmi=".../XMI" xmlns:xsi=".../2001/XMLSchema-instance"
xmlns:ecore=".../emf/2002/Ecore" name="source"
nsURI="source" nsPrefix="">
...

now I get xmi as:

<?xml version="1.0" encoding="ISO-8859-1"?>
<Device xmi:version="2.0" xmlns:xmi=".../XMI" xmlns:xsi=".../2001/XMLSchema-instance" xmlns="target" name="PSSuniversal22222" s7DeviceReference="{7F6AC5F1-E8E0-49E5-ABA1-26E4A6A74175}{001417C3-00000003-001417B3-00000002-00112001-00000107}{SD_example1}">
...
</Device>



java code is:

if (args.length == 0) {
System.out.println("Enter a list of file paths or URIs that have content like this:");
try {
Resource resource = resourceSet.createResource(URI.createURI("C:/.../tpfOut.xmi"));
Device root = TargetFactory.eINSTANCE.createDevice();
resource.getContents().add(root);
resource.save(System.out, null);
System.out.println(root);
}




output is:

Enter a list of file paths or URIs that have content like this:
<?xml version="1.0" encoding="ASCII"?>
<Device xmi:version="2.0" xmlns:xmi=".../XMI" xmlns="target"/>
target.impl.DeviceImpl@aaa392 (name: null, s7DeviceReference: null)


still null data.

Re: XMI to java objects [message #878988 is a reply to message #878937] Wed, 30 May 2012 10:10 Go to previous messageGo to next message
Kosala Yapa is currently offline Kosala YapaFriend
Messages: 159
Registered: September 2010
Senior Member
what is the use of edit and editor created from genmodel?
Re: XMI to java objects [message #879028 is a reply to message #878953] Wed, 30 May 2012 11:37 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33133
Registered: July 2009
Senior Member
Kosala,

Comments below.

On 30/05/2012 11:06 AM, Kosala Yapa wrote:
> EPackage:
>
> <ecore:EPackage xmi:version="2.0"
> xmlns:xmi=".../XMI" xmlns:xsi=".../2001/XMLSchema-instance"
> xmlns:ecore=".../emf/2002/Ecore" name="source"
> nsURI="source" nsPrefix="">
> ..
>
> now I get xmi as:
>
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <Device xmi:version="2.0" xmlns:xmi=".../XMI"
> xmlns:xsi=".../2001/XMLSchema-instance" xmlns="target"
I'd expect this to be "source".
> name="PSSuniversal22222"
> s7DeviceReference="{7F6AC5F1-E8E0-49E5-ABA1-26E4A6A74175}{001417C3-00000003-001417B3-00000002-00112001-00000107}{SD_example1}">
> ..
> </Device>
>
>
>
> java code is:
>
> if (args.length == 0) {
> System.out.println("Enter a list of file paths or URIs
> that have content like this:");
> try {
> Resource resource =
> resourceSet.createResource(URI.createURI("C:/.../tpfOut.xmi"));
> Device root = TargetFactory.eINSTANCE.createDevice();
> resource.getContents().add(root);
> resource.save(System.out, null);
> System.out.println(root);
> }
>
>
>
>
> output is:
>
> Enter a list of file paths or URIs that have content like this:
> <?xml version="1.0" encoding="ASCII"?>
> <Device xmi:version="2.0" xmlns:xmi=".../XMI" xmlns="target"/>
> mailto:target.impl.DeviceImpl@aaa392 (name: null, s7DeviceReference:
> null)
You've created resource with an empty new object where you haven't
populated any data.
>
>
> still null data.
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: XMI to java objects [message #879029 is a reply to message #878988] Wed, 30 May 2012 11:37 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33133
Registered: July 2009
Senior Member
Kosala,

So you can edit (read/write/modify) instances of your model.

On 30/05/2012 12:10 PM, Kosala Yapa wrote:
> what is the use of edit and editor created from genmodel?


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: XMI to java objects [message #879625 is a reply to message #879029] Thu, 31 May 2012 14:35 Go to previous messageGo to next message
Kosala Yapa is currently offline Kosala YapaFriend
Messages: 159
Registered: September 2010
Senior Member
Hi,

This is done now. Thanks a million Merks.

Presently, I am running this ATL program using eclipse Run Configuration. I am exploring, how to run this transformation using a java program.
org.eclipse.m2m.atl.engine.AtlLauncher looks like a possible approach.

Do you have any clue, any easy way to do this?

Thanks
Kosala
Re: XMI to java objects [message #879637 is a reply to message #879625] Thu, 31 May 2012 14:59 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33133
Registered: July 2009
Senior Member
Best to ask on the ATL newsgroup.

On 31/05/2012 4:35 PM, Kosala Yapa wrote:
> Hi,
>
> This is done now. Thanks a million Merks.
> Presently, I am running this ATL program using eclipse Run
> Configuration. I am exploring, how to run this transformation using a
> java program.
> org.eclipse.m2m.atl.engine.AtlLauncher looks like a possible approach.
>
> Do you have any clue, any easy way to do this?
>
> Thanks
> Kosala


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:[CDO(/Teneo/Hibernate)] reordering of ELists
Next Topic:EMF / CDO Transaction conflict
Goto Forum:
  


Current Time: Tue Apr 16 22:01:59 GMT 2024

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

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

Back to the top