Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Problems during serialization with cross-references
Problems during serialization with cross-references [message #420925] Wed, 16 July 2008 15:21 Go to next message
Timothy Marc is currently offline Timothy MarcFriend
Messages: 547
Registered: July 2009
Senior Member
Hi all,

first, let me explain my problem.

I have created a model manually. In that model, i included another resource
with the "Load Resource"-functionality of the generated EMF-Editor.

Now, i want to generate the same model programmatically, but i had some
problems with the serialization.

Here is my code, that writes out the model:

final XMIResource resource = new
XMIResourceImpl(URI.createFileURI(" D:/workspaces/testingWorkbench/runtime-EclipseApplication/te stiingMM/model/CommitTest_PST_gen.testing "));
resource.getContents().add(pst);
try {
resource.save(null);
} catch (IOException e) {
e.printStackTrace();
}

Nothing unusual, i think. So, these are my problems:

1. org.eclipse.emf.ecore.xmi.FeatureNotFoundException: Feature 'version' not
found. (platform:/resource/testiingMM/model/CommitTest_PST_gen.test ing, 2,
326)

2. org.eclipse.emf.ecore.xmi.FeatureNotFoundException: Feature 'href' not
found. (platform:/resource/testiingMM/model/CommitTest_PST_gen.test ing, 6,
139)

The related element in the XMI looks like:

<ownedElements xsi:type="modelplex.testing.foundation:Property"
name="mesagge">

<theType xsi:type="modelplex.testing.foundation:PrimitiveType"
href="TestingMMPrimitiveTypes.library.testing#//@ownedElements.0 "/>

</ownedElements>

It seems to me, like the theType element is contained by message:Property,
what isn't so.

The manual created element looks like this:

<ownedElements xsi:type="modelplex.testing.foundation:Property"
id="CommitTest_PST_structure_CommitRequest_file" name="rq_file"
theType="modelplex.testing.foundation:PrimitiveType
TestingMMPrimitiveTypes.library.testing#//@ownedElements.0"/ >

How to get thinks working programmatically, like they would have been
created and crossed linked via "Load Ressource"?

Thanks at all

Timothy
Re: Problems during serialization with cross-references [message #420930 is a reply to message #420925] Wed, 16 July 2008 15:57 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33133
Registered: July 2009
Senior Member
Timothy,

Gosh but there are a lot of questions today. I hope I don't go insane.


Timothy Marc wrote:
> Hi all,
>
> first, let me explain my problem.
>
> I have created a model manually. In that model, i included another resource
> with the "Load Resource"-functionality of the generated EMF-Editor.
>
> Now, i want to generate the same model programmatically, but i had some
> problems with the serialization.
>
> Here is my code, that writes out the model:
>
> final XMIResource resource = new
> XMIResourceImpl(URI.createFileURI(" D:/workspaces/testingWorkbench/runtime-EclipseApplication/te stiingMM/model/CommitTest_PST_gen.testing "));
> resource.getContents().add(pst);
> try {
> resource.save(null);
> } catch (IOException e) {
> e.printStackTrace();
> }
>
> Nothing unusual, i think. So, these are my problems:
>
> 1. org.eclipse.emf.ecore.xmi.FeatureNotFoundException: Feature 'version' not
> found. (platform:/resource/testiingMM/model/CommitTest_PST_gen.test ing, 2,
> 326)
>
> 2. org.eclipse.emf.ecore.xmi.FeatureNotFoundException: Feature 'href' not
> found. (platform:/resource/testiingMM/model/CommitTest_PST_gen.test ing, 6,
> 139)
>
>
These sound like load problems and the code above is doing a save. I'd
expect problems like the one above if the resource doing the loading
isn't expecting XMI. Note that if you invoke "Generate Test Code" and
look in the *.tests projects there's a generated XyzExample.java which
shows a good example of how to load and save resources.
> The related element in the XMI looks like:
>
> <ownedElements xsi:type="modelplex.testing.foundation:Property"
> name="mesagge">
>
> <theType xsi:type="modelplex.testing.foundation:PrimitiveType"
> href="TestingMMPrimitiveTypes.library.testing#//@ownedElements.0 "/>
>
> </ownedElements>
>
> It seems to me, like the theType element is contained by message:Property,
> what isn't so.
>
> The manual created element looks like this:
>
> <ownedElements xsi:type="modelplex.testing.foundation:Property"
> id="CommitTest_PST_structure_CommitRequest_file" name="rq_file"
> theType="modelplex.testing.foundation:PrimitiveType
> TestingMMPrimitiveTypes.library.testing#//@ownedElements.0"/ >
>
If this is an XMI serialization, it's using different options. Note
that the way you created the resource bypasses the option set in the
resource factory.
> How to get thinks working programmatically, like they would have been
> created and crossed linked via "Load Ressource"?
>
Probably the generated example will help.
> Thanks at all
>
> Timothy
>
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Problems during serialization with cross-references [message #420952 is a reply to message #420930] Thu, 17 July 2008 11:12 Go to previous messageGo to next message
Timothy Marc is currently offline Timothy MarcFriend
Messages: 547
Registered: July 2009
Senior Member
Dear Ed,

sorry for mentioning imprecise code snippets. The exceptions, i mentioned,
are surely during the load operation in the generated Editor. I saved them
with the snippet i have shown (it is very close to the code in
XYZExample.java), but i can'topen it in the generated Editor. I even try to
create not an XMI/XML Resource but a domain-specific one, which was
generated in the util-Package of my model. In my case its name is
TestingResourceImpl.

When i create a model by using the generated tree editor, the editor
serializes the model as what kind of resource? I'm wondering why the
type-element, i mentioned in the post before, is one hand an attribute of an
element (like i want it to be) and on the other hand, by programmatically
creating the same model, a contained element of that element?

Thx
-- Timothy


"Ed Merks" <Ed.Merks@gmail.com> schrieb im Newsbeitrag
news:g5l5pi$t20$1@build.eclipse.org...
> Timothy,
>
> Gosh but there are a lot of questions today. I hope I don't go insane.
>
>
> Timothy Marc wrote:
>> Hi all,
>>
>> first, let me explain my problem.
>>
>> I have created a model manually. In that model, i included another
>> resource with the "Load Resource"-functionality of the generated
>> EMF-Editor.
>>
>> Now, i want to generate the same model programmatically, but i had some
>> problems with the serialization.
>>
>> Here is my code, that writes out the model:
>>
>> final XMIResource resource = new
>> XMIResourceImpl(URI.createFileURI(" D:/workspaces/testingWorkbench/runtime-EclipseApplication/te stiingMM/model/CommitTest_PST_gen.testing "));
>> resource.getContents().add(pst);
>> try {
>> resource.save(null);
>> } catch (IOException e) {
>> e.printStackTrace();
>> }
>>
>> Nothing unusual, i think. So, these are my problems:
>>
>> 1. org.eclipse.emf.ecore.xmi.FeatureNotFoundException: Feature 'version'
>> not found.
>> (platform:/resource/testiingMM/model/CommitTest_PST_gen.test ing, 2, 326)
>>
>> 2. org.eclipse.emf.ecore.xmi.FeatureNotFoundException: Feature 'href' not
>> found. (platform:/resource/testiingMM/model/CommitTest_PST_gen.test ing,
>> 6, 139)
>>
>>
> These sound like load problems and the code above is doing a save. I'd
> expect problems like the one above if the resource doing the loading isn't
> expecting XMI. Note that if you invoke "Generate Test Code" and look in
> the *.tests projects there's a generated XyzExample.java which shows a
> good example of how to load and save resources.
>> The related element in the XMI looks like:
>>
>> <ownedElements xsi:type="modelplex.testing.foundation:Property"
>> name="mesagge">
>>
>> <theType xsi:type="modelplex.testing.foundation:PrimitiveType"
>> href="TestingMMPrimitiveTypes.library.testing#//@ownedElements.0 "/>
>>
>> </ownedElements>
>>
>> It seems to me, like the theType element is contained by
>> message:Property, what isn't so.
>>
>> The manual created element looks like this:
>>
>> <ownedElements xsi:type="modelplex.testing.foundation:Property"
>> id="CommitTest_PST_structure_CommitRequest_file" name="rq_file"
>> theType="modelplex.testing.foundation:PrimitiveType
>> TestingMMPrimitiveTypes.library.testing#//@ownedElements.0"/ >
>>
> If this is an XMI serialization, it's using different options. Note that
> the way you created the resource bypasses the option set in the resource
> factory.
>> How to get thinks working programmatically, like they would have been
>> created and crossed linked via "Load Ressource"?
>>
> Probably the generated example will help.
>> Thanks at all
>>
>> Timothy
>>
>>
>>
Re: Problems during serialization with cross-references [message #420955 is a reply to message #420952] Thu, 17 July 2008 11:20 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33133
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------030109050704000700030803
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Timothy,

Comments below.

Timothy Marc wrote:
> Dear Ed,
>
> sorry for mentioning imprecise code snippets. The exceptions, i mentioned,
> are surely during the load operation in the generated Editor. I saved them
> with the snippet i have shown (it is very close to the code in
> XYZExample.java)
It didn't look so close to me.
> , but i can'topen it in the generated Editor.
That makes it clear to me that they are using different serialization
approaches or significantly different options. Look carefully at the
resource factory being used to create the resource in each case.
> I even try to
> create not an XMI/XML Resource but a domain-specific one, which was
> generated in the util-Package of my model. In my case its name is
> TestingResourceImpl.
>
Again, be sure to look closely at the factory that creates this
implementation class. Be sure that in both cases the same factory is
being used for both load and save.
> When i create a model by using the generated tree editor, the editor
> serializes the model as what kind of resource?
That depends on your registrations. If all goes well, I'd expect your
TestingResourceFactoryImpl's createResource to end up being called.
> I'm wondering why the
> type-element, i mentioned in the post before, is one hand an attribute of an
> element (like i want it to be) and on the other hand, by programmatically
> creating the same model, a contained element of that element?
>
An XMIResourceImpl will tend to serialize cross resource references
using <owner><feature-name href="reference"/></owner> but an
XMLResourceImpl will use <owner feature-name="reference"/>.
> Thx
> -- Timothy
>
>
> "Ed Merks" <Ed.Merks@gmail.com> schrieb im Newsbeitrag
> news:g5l5pi$t20$1@build.eclipse.org...
>
>> Timothy,
>>
>> Gosh but there are a lot of questions today. I hope I don't go insane.
>>
>>
>> Timothy Marc wrote:
>>
>>> Hi all,
>>>
>>> first, let me explain my problem.
>>>
>>> I have created a model manually. In that model, i included another
>>> resource with the "Load Resource"-functionality of the generated
>>> EMF-Editor.
>>>
>>> Now, i want to generate the same model programmatically, but i had some
>>> problems with the serialization.
>>>
>>> Here is my code, that writes out the model:
>>>
>>> final XMIResource resource = new
>>> XMIResourceImpl(URI.createFileURI(" D:/workspaces/testingWorkbench/runtime-EclipseApplication/te stiingMM/model/CommitTest_PST_gen.testing "));
>>> resource.getContents().add(pst);
>>> try {
>>> resource.save(null);
>>> } catch (IOException e) {
>>> e.printStackTrace();
>>> }
>>>
>>> Nothing unusual, i think. So, these are my problems:
>>>
>>> 1. org.eclipse.emf.ecore.xmi.FeatureNotFoundException: Feature 'version'
>>> not found.
>>> (platform:/resource/testiingMM/model/CommitTest_PST_gen.test ing, 2, 326)
>>>
>>> 2. org.eclipse.emf.ecore.xmi.FeatureNotFoundException: Feature 'href' not
>>> found. (platform:/resource/testiingMM/model/CommitTest_PST_gen.test ing,
>>> 6, 139)
>>>
>>>
>>>
>> These sound like load problems and the code above is doing a save. I'd
>> expect problems like the one above if the resource doing the loading isn't
>> expecting XMI. Note that if you invoke "Generate Test Code" and look in
>> the *.tests projects there's a generated XyzExample.java which shows a
>> good example of how to load and save resources.
>>
>>> The related element in the XMI looks like:
>>>
>>> <ownedElements xsi:type="modelplex.testing.foundation:Property"
>>> name="mesagge">
>>>
>>> <theType xsi:type="modelplex.testing.foundation:PrimitiveType"
>>> href="TestingMMPrimitiveTypes.library.testing#//@ownedElements.0 "/>
>>>
>>> </ownedElements>
>>>
>>> It seems to me, like the theType element is contained by
>>> message:Property, what isn't so.
>>>
>>> The manual created element looks like this:
>>>
>>> <ownedElements xsi:type="modelplex.testing.foundation:Property"
>>> id="CommitTest_PST_structure_CommitRequest_file" name="rq_file"
>>> theType="modelplex.testing.foundation:PrimitiveType
>>> TestingMMPrimitiveTypes.library.testing#//@ownedElements.0"/ >
>>>
>>>
>> If this is an XMI serialization, it's using different options. Note that
>> the way you created the resource bypasses the option set in the resource
>> factory.
>>
>>> How to get thinks working programmatically, like they would have been
>>> created and crossed linked via "Load Ressource"?
>>>
>>>
>> Probably the generated example will help.
>>
>>> Thanks at all
>>>
>>> Timothy
>>>
>>>
>>>
>>>
>
>
>
>

--------------030109050704000700030803
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Timothy,<br>
<br>
Comments below.<br>
<br>
Timothy Marc wrote:
<blockquote cite="mid:g5n9b9$qtp$1@build.eclipse.org" type="cite">
<pre wrap="">Dear Ed,

sorry for mentioning imprecise code snippets. The exceptions, i mentioned,
are surely during the load operation in the generated Editor. I saved them
with the snippet i have shown (it is very close to the code in
XYZExample.java)</pre>
</blockquote>
It didn't look so close to me.<br>
<blockquote cite="mid:g5n9b9$qtp$1@build.eclipse.org" type="cite">
<pre wrap="">, but i can'topen it in the generated Editor. </pre>
</blockquote>
That makes it clear to me that they are using different serialization
approaches or significantly different options.&nbsp; Look carefully at the
resource factory being used to create the resource in each case.<br>
<blockquote cite="mid:g5n9b9$qtp$1@build.eclipse.org" type="cite">
<pre wrap="">I even try to
create not an XMI/XML Resource but a domain-specific one, which was
generated in the util-Package of my model. In my case its name is
TestingResourceImpl.
</pre>
</blockquote>
Again, be sure to look closely at the factory that creates this
implementation class.&nbsp; Be sure that in both cases the same factory is
being used for both load and save.<br>
<blockquote cite="mid:g5n9b9$qtp$1@build.eclipse.org" type="cite">
<pre wrap="">
When i create a model by using the generated tree editor, the editor
serializes the model as what kind of resource? </pre>
</blockquote>
That depends on your registrations.&nbsp; If all goes well, I'd expect your
TestingResourceFactoryImpl's createResource to end up being called.<br>
<blockquote cite="mid:g5n9b9$qtp$1@build.eclipse.org" type="cite">
<pre wrap="">I'm wondering why the
type-element, i mentioned in the post before, is one hand an attribute of an
element (like i want it to be) and on the other hand, by programmatically
creating the same model, a contained element of that element?
</pre>
</blockquote>
An XMIResourceImpl will tend to serialize cross resource references
using &lt;owner&gt;&lt;feature-name href="reference"/&gt;&lt;/owner&gt;
but an XMLResourceImpl will use &lt;owner feature-name="reference"/&gt;.<br>
<blockquote cite="mid:g5n9b9$qtp$1@build.eclipse.org" type="cite">
<pre wrap="">
Thx
-- Timothy


"Ed Merks" <a class="moz-txt-link-rfc2396E" href="mailto:Ed.Merks@gmail.com">&lt;Ed.Merks@gmail.com&gt;</a> schrieb im Newsbeitrag
<a class="moz-txt-link-freetext" href="news:g5l5pi$t20$1@build.eclipse.org">news:g5l5pi$t20$1@build.eclipse.org</a>...
</pre>
<blockquote type="cite">
<pre wrap="">Timothy,

Gosh but there are a lot of questions today. I hope I don't go insane.


Timothy Marc wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Hi all,

first, let me explain my problem.

I have created a model manually. In that model, i included another
resource with the "Load Resource"-functionality of the generated
EMF-Editor.

Now, i want to generate the same model programmatically, but i had some
problems with the serialization.

Here is my code, that writes out the model:

final XMIResource resource = new
XMIResourceImpl(URI.createFileURI(" D:/workspaces/testingWorkbench/runtime-EclipseApplication/te stiingMM/model/CommitTest_PST_gen.testing "));
resource.getContents().add(pst);
try {
resource.save(null);
} catch (IOException e) {
e.printStackTrace();
}

Nothing unusual, i think. So, these are my problems:

1. org.eclipse.emf.ecore.xmi.FeatureNotFoundException: Feature 'version'
not found.
(platform:/resource/testiingMM/model/CommitTest_PST_gen.test ing, 2, 326)

2. org.eclipse.emf.ecore.xmi.FeatureNotFoundException: Feature 'href' not
found. (platform:/resource/testiingMM/model/CommitTest_PST_gen.test ing,
6, 139)


</pre>
</blockquote>
<pre wrap="">These sound like load problems and the code above is doing a save. I'd
expect problems like the one above if the resource doing the loading isn't
expecting XMI. Note that if you invoke "Generate Test Code" and look in
the *.tests projects there's a generated XyzExample.java which shows a
good example of how to load and save resources.
</pre>
<blockquote type="cite">
<pre wrap="">The related element in the XMI looks like:

&lt;ownedElements xsi:type="modelplex.testing.foundation:Property"
name="mesagge"&gt;

&lt;theType xsi:type="modelplex.testing.foundation:PrimitiveType"
href=<a class="moz-txt-link-rfc2396E" href=" mailto:TestingMMPrimitiveTypes.library.testing#//@ownedEleme nts.0 ">"TestingMMPrimitiveTypes.library.testing#//@ownedElements.0 "</a>/&gt;

&lt;/ownedElements&gt;

It seems to me, like the theType element is contained by
message:Property, what isn't so.

The manual created element looks like this:

&lt;ownedElements xsi:type="modelplex.testing.foundation:Property"
id="CommitTest_PST_structure_CommitRequest_file" name="rq_file"
theType="modelplex.testing.foundation:PrimitiveType
<a class="moz-txt-link-abbreviated" href=" mailto:TestingMMPrimitiveTypes.library.testing#//@ownedEleme nts.0 ">TestingMMPrimitiveTypes.library.testing#//@ownedElements.0 </a>"/&gt;

</pre>
</blockquote>
<pre wrap="">If this is an XMI serialization, it's using different options. Note that
the way you created the resource bypasses the option set in the resource
factory.
</pre>
<blockquote type="cite">
<pre wrap="">How to get thinks working programmatically, like they would have been
created and crossed linked via "Load Ressource"?

</pre>
</blockquote>
<pre wrap="">Probably the generated example will help.
</pre>
<blockquote type="cite">
<pre wrap="">Thanks at all

Timothy



</pre>
</blockquote>
</blockquote>
<pre wrap=""><!---->


</pre>
</blockquote>
</body>
</html>

--------------030109050704000700030803--


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Problems during serialization with cross-references [message #420959 is a reply to message #420955] Thu, 17 July 2008 11:52 Go to previous messageGo to next message
Timothy Marc is currently offline Timothy MarcFriend
Messages: 547
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.

------=_NextPart_000_003A_01C8E814.54461C50
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Dear Ed,

thanks again, it works fine now. I think i now get the ideas of all =
these Factories in EMF. So, if i want the Editor to serialize my model =
as XMI, i have to change it in the model-specific Factory,i.e. in the =
createResource method.

Thanks for your patience.

Timothy
"Ed Merks" <Ed.Merks@gmail.com> schrieb im Newsbeitrag =
news:g5n9u9$2n3$1@build.eclipse.org...
Timothy,

Comments below.

Timothy Marc wrote:=20
Dear Ed,

sorry for mentioning imprecise code snippets. The exceptions, i =
mentioned,
are surely during the load operation in the generated Editor. I saved =
them
with the snippet i have shown (it is very close to the code in
XYZExample.java)It didn't look so close to me.

, but i can'topen it in the generated Editor. That makes it clear to me =
that they are using different serialization approaches or significantly =
different options. Look carefully at the resource factory being used to =
create the resource in each case.

I even try to=20
create not an XMI/XML Resource but a domain-specific one, which was=20
generated in the util-Package of my model. In my case its name is=20
TestingResourceImpl.
Again, be sure to look closely at the factory that creates this =
implementation class. Be sure that in both cases the same factory is =
being used for both load and save.

When i create a model by using the generated tree editor, the editor=20
serializes the model as what kind of resource? That depends on your =
registrations. If all goes well, I'd expect your =
TestingResourceFactoryImpl's createResource to end up being called.

I'm wondering why the=20
type-element, i mentioned in the post before, is one hand an attribute =
of an=20
element (like i want it to be) and on the other hand, by =
programmatically=20
creating the same model, a contained element of that element?
An XMIResourceImpl will tend to serialize cross resource references =
using <owner><feature-name href=3D"reference"/></owner> but an =
XMLResourceImpl will use <owner feature-name=3D"reference"/>.

Thx
-- Timothy


"Ed Merks" <Ed.Merks@gmail.com> schrieb im Newsbeitrag
news:g5l5pi$t20$1@build.eclipse.org...
Timothy,

Gosh but there are a lot of questions today. I hope I don't go insane.


Timothy Marc wrote:
Hi all,

first, let me explain my problem.

I have created a model manually. In that model, i included another
resource with the "Load Resource"-functionality of the generated
EMF-Editor.

Now, i want to generate the same model programmatically, but i had some
problems with the serialization.

Here is my code, that writes out the model:

final XMIResource resource =3D new
XMIResourceImpl(URI.createFileURI("D:/workspaces/testingWorkbench/runtime=
-EclipseApplication/testiingMM/model/CommitTest_PST_gen.test ing "));
resource.getContents().add(pst);
try {
resource.save(null);
} catch (IOException e) {
e.printStackTrace();
}

Nothing unusual, i think. So, these are my problems:

1. org.eclipse.emf.ecore.xmi.FeatureNotFoundException: Feature 'version'
not found.
(platform:/resource/testiingMM/model/CommitTest_PST_gen.test ing, 2, 326)

2. org.eclipse.emf.ecore.xmi.FeatureNotFoundException: Feature 'href' =
not
found. (platform:/resource/testiingMM/model/CommitTest_PST_gen.test ing,
6, 139)


These sound like load problems and the code above is doing a save. =
I'd
expect problems like the one above if the resource doing the loading =
isn't
expecting XMI. Note that if you invoke "Generate Test Code" and look in
the *.tests projects there's a generated XyzExample.java which shows a
good example of how to load and save resources.
The related element in the XMI looks like:

<ownedElements xsi:type=3D"modelplex.testing.foundation:Property"
name=3D"mesagge">

<theType xsi:type=3D"modelplex.testing.foundation:PrimitiveType"
href=3D"TestingMMPrimitiveTypes.library.testing#//@ownedElements.0 "/>

</ownedElements>

It seems to me, like the theType element is contained by
message:Property, what isn't so.

The manual created element looks like this:

<ownedElements xsi:type=3D"modelplex.testing.foundation:Property"
id=3D"CommitTest_PST_structure_CommitRequest_file" name=3D"rq_file"
theType=3D"modelplex.testing.foundation:PrimitiveType
TestingMMPrimitiveTypes.library.testing#//@ownedElements.0"/ >

If this is an XMI serialization, it's using different options. =
Note that
the way you created the resource bypasses the option set in the resource
factory.
How to get thinks working programmatically, like they would have =
been
created and crossed linked via "Load Ressource"?

Probably the generated example will help.
Thanks at all

Timothy



=20



------=_NextPart_000_003A_01C8E814.54461C50
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type =
content=3Dtext/html;charset=3DISO-8859-1>
<META content=3D"MSHTML 6.00.2900.3354" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY text=3D#000000 bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Dear Ed,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>thanks again, it works fine now. I =
think i now get=20
the ideas of all these Factories in EMF. So, if i want the Editor to =
serialize=20
my model as XMI, i have to change it in the model-specific Factory,i.e. =
in the=20
createResource method.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Thanks for your patience.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Timothy</FONT></DIV>
<BLOCKQUOTE dir=3Dltr=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Ed Merks" &lt;<A=20
href=3D"mailto:Ed.Merks@gmail.com">Ed.Merks@gmail.com</A>&gt; schrieb =
im=20
Newsbeitrag <A=20
=
href=3D"news:g5n9u9$2n3$1@build.eclipse.org">news:g5n9u9$2n3$1@build.ecli=
pse.org</A>...</DIV>Timothy,<BR><BR>Comments=20
below.<BR><BR>Timothy Marc wrote:=20
<BLOCKQUOTE cite=3Dmid:g5n9b9$qtp$1@build.eclipse.org =
type=3D"cite"><PRE wrap=3D"">Dear Ed,

sorry for mentioning imprecise code snippets. The exceptions, i =
mentioned,
are surely during the load operation in the generated Editor. I saved =
them
with the snippet i have shown (it is very close to the code in
XYZExample.java)</PRE></BLOCKQUOTE>It didn't look so close to me.<BR>
<BLOCKQUOTE cite=3Dmid:g5n9b9$qtp$1@build.eclipse.org =
type=3D"cite"><PRE wrap=3D"">, but i can'topen it in the generated =
Editor. </PRE></BLOCKQUOTE>That=20
makes it clear to me that they are using different serialization =
approaches or=20
significantly different options.&nbsp; Look carefully at the resource =
factory=20
being used to create the resource in each case.<BR>
<BLOCKQUOTE cite=3Dmid:g5n9b9$qtp$1@build.eclipse.org =
type=3D"cite"><PRE wrap=3D"">I even try to=20
create not an XMI/XML Resource but a domain-specific one, which was=20
generated in the util-Package of my model. In my case its name is=20
TestingResourceImpl.
</PRE></BLOCKQUOTE>Again, be sure to look closely at the factory that=20
creates this implementation class.&nbsp; Be sure that in both cases =
the same=20
factory is being used for both load and save.<BR>
<BLOCKQUOTE cite=3Dmid:g5n9b9$qtp$1@build.eclipse.org =
type=3D"cite"><PRE wrap=3D"">When i create a model by using the =
generated tree editor, the editor=20
serializes the model as what kind of resource? </PRE></BLOCKQUOTE>That =
depends=20
on your registrations.&nbsp; If all goes well, I'd expect your=20
TestingResourceFactoryImpl's createResource to end up being =
called.<BR>
<BLOCKQUOTE cite=3Dmid:g5n9b9$qtp$1@build.eclipse.org =
type=3D"cite"><PRE wrap=3D"">I'm wondering why the=20
type-element, i mentioned in the post before, is one hand an attribute =
of an=20
element (like i want it to be) and on the other hand, by =
programmatically=20
creating the same model, a contained element of that element?
</PRE></BLOCKQUOTE>An XMIResourceImpl will tend to serialize cross =
resource=20
references using &lt;owner&gt;&lt;feature-name=20
href=3D"reference"/&gt;&lt;/owner&gt; but an XMLResourceImpl will use =
&lt;owner=20
feature-name=3D"reference"/&gt;.<BR>
<BLOCKQUOTE cite=3Dmid:g5n9b9$qtp$1@build.eclipse.org =
type=3D"cite"><PRE wrap=3D"">Thx
-- Timothy


"Ed Merks" <A class=3Dmoz-txt-link-rfc2396E =
href=3D"mailto:Ed.Merks@gmail.com">&lt;Ed.Merks@gmail.com&gt;</A> =
schrieb im Newsbeitrag
<A class=3Dmoz-txt-link-freetext =
href=3D"news:g5l5pi$t20$1@build.eclipse.org">news:g5l5pi$t20$1@build.ecli=
pse.org</A>...
</PRE>
<BLOCKQUOTE type=3D"cite"><PRE wrap=3D"">Timothy,

Gosh but there are a lot of questions today. I hope I don't go insane.


Timothy Marc wrote:
</PRE>
<BLOCKQUOTE type=3D"cite"><PRE wrap=3D"">Hi all,

first, let me explain my problem.

I have created a model manually. In that model, i included another
resource with the "Load Resource"-functionality of the generated
EMF-Editor.

Now, i want to generate the same model programmatically, but i had some
problems with the serialization.

Here is my code, that writes out the model:

final XMIResource resource =3D new
XMIResourceImpl(URI.createFileURI("D:/workspaces/testingWorkbench/runtime=
-EclipseApplication/testiingMM/model/CommitTest_PST_gen.test ing "));
resource.getContents().add(pst);
try {
resource.save(null);
} catch (IOException e) {
e.printStackTrace();
}

Nothing unusual, i think. So, these are my problems:

1. org.eclipse.emf.ecore.xmi.FeatureNotFoundException: Feature 'version'
not found.
(platform:/resource/testiingMM/model/CommitTest_PST_gen.test ing, 2, 326)

2. org.eclipse.emf.ecore.xmi.FeatureNotFoundException: Feature 'href' =
not
found. (platform:/resource/testiingMM/model/CommitTest_PST_gen.test ing,
6, 139)


</PRE></BLOCKQUOTE><PRE wrap=3D"">These sound like load problems =
and the code above is doing a save. I'd
expect problems like the one above if the resource doing the loading =
isn't
expecting XMI. Note that if you invoke "Generate Test Code" and look in
the *.tests projects there's a generated XyzExample.java which shows a
good example of how to load and save resources.
</PRE>
<BLOCKQUOTE type=3D"cite"><PRE wrap=3D"">The related element in =
the XMI looks like:

&lt;ownedElements xsi:type=3D"modelplex.testing.foundation:Property"
name=3D"mesagge"&gt;

&lt;theType xsi:type=3D"modelplex.testing.foundation:PrimitiveType"
href=3D<A class=3Dmoz-txt-link-rfc2396E =
href=3D" mailto:TestingMMPrimitiveTypes.library.testing#//@ownedEleme nts.0=
">"TestingMMPrimitiveTypes.library.testing#//@ownedElements.0 "</A>/&gt;

&lt;/ownedElements&gt;

It seems to me, like the theType element is contained by
message:Property, what isn't so.

The manual created element looks like this:

&lt;ownedElements xsi:type=3D"modelplex.testing.foundation:Property"
id=3D"CommitTest_PST_structure_CommitRequest_file" name=3D"rq_file"
theType=3D"modelplex.testing.foundation:PrimitiveType
<A class=3Dmoz-txt-link-abbreviated =
href=3D" mailto:TestingMMPrimitiveTypes.library.testing#//@ownedEleme nts.0=
">TestingMMPrimitiveTypes.library.testing#//@ownedElements.0 </A>"/&gt;

</PRE></BLOCKQUOTE><PRE wrap=3D"">If this is an XMI serialization, =
it's using different options. Note that
the way you created the resource bypasses the option set in the resource
factory.
</PRE>
<BLOCKQUOTE type=3D"cite"><PRE wrap=3D"">How to get thinks working =
programmatically, like they would have been
created and crossed linked via "Load Ressource"?

</PRE></BLOCKQUOTE><PRE wrap=3D"">Probably the generated example =
will help.
</PRE>
<BLOCKQUOTE type=3D"cite"><PRE wrap=3D"">Thanks at all

Timothy



</PRE></BLOCKQUOTE></BLOCKQUOTE><PRE wrap=3D""><!---->


</PRE></BLOCKQUOTE></BLOCKQUOTE></BODY></HTML>

------=_NextPart_000_003A_01C8E814.54461C50--
Re: Problems during serialization with cross-references [message #420960 is a reply to message #420959] Thu, 17 July 2008 12:18 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33133
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------000401020802050903040801
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Timothy,

Yes, factories are a very important concept since this ensures that when
handling your type of resource, the right options and right choice of
resource implementation is consistently made. There are even GenPackage
options to switch between XMI and XML resources, but yes, generally
tailoring will be done by specializing with the createResource method
does in the factory.


Timothy Marc wrote:
> Dear Ed,
>
> thanks again, it works fine now. I think i now get the ideas of all
> these Factories in EMF. So, if i want the Editor to serialize my model
> as XMI, i have to change it in the model-specific Factory,i.e. in the
> createResource method.
>
> Thanks for your patience.
>
> Timothy
>
> "Ed Merks" <Ed.Merks@gmail.com <mailto:Ed.Merks@gmail.com>>
> schrieb im Newsbeitrag news:g5n9u9$2n3$1@build.eclipse.org...
> Timothy,
>
> Comments below.
>
> Timothy Marc wrote:
>> Dear Ed,
>>
>> sorry for mentioning imprecise code snippets. The exceptions, i mentioned,
>> are surely during the load operation in the generated Editor. I saved them
>> with the snippet i have shown (it is very close to the code in
>> XYZExample.java)
> It didn't look so close to me.
>> , but i can'topen it in the generated Editor.
> That makes it clear to me that they are using different
> serialization approaches or significantly different options. Look
> carefully at the resource factory being used to create the
> resource in each case.
>> I even try to
>> create not an XMI/XML Resource but a domain-specific one, which was
>> generated in the util-Package of my model. In my case its name is
>> TestingResourceImpl.
>>
> Again, be sure to look closely at the factory that creates this
> implementation class. Be sure that in both cases the same factory
> is being used for both load and save.
>> When i create a model by using the generated tree editor, the editor
>> serializes the model as what kind of resource?
> That depends on your registrations. If all goes well, I'd expect
> your TestingResourceFactoryImpl's createResource to end up being
> called.
>> I'm wondering why the
>> type-element, i mentioned in the post before, is one hand an attribute of an
>> element (like i want it to be) and on the other hand, by programmatically
>> creating the same model, a contained element of that element?
>>
> An XMIResourceImpl will tend to serialize cross resource
> references using <owner><feature-name href="reference"/></owner>
> but an XMLResourceImpl will use <owner feature-name="reference"/>.
>> Thx
>> -- Timothy
>>
>>
>> "Ed Merks" <Ed.Merks@gmail.com> schrieb im Newsbeitrag
>> news:g5l5pi$t20$1@build.eclipse.org...
>>
>>> Timothy,
>>>
>>> Gosh but there are a lot of questions today. I hope I don't go insane.
>>>
>>>
>>> Timothy Marc wrote:
>>>
>>>> Hi all,
>>>>
>>>> first, let me explain my problem.
>>>>
>>>> I have created a model manually. In that model, i included another
>>>> resource with the "Load Resource"-functionality of the generated
>>>> EMF-Editor.
>>>>
>>>> Now, i want to generate the same model programmatically, but i had some
>>>> problems with the serialization.
>>>>
>>>> Here is my code, that writes out the model:
>>>>
>>>> final XMIResource resource = new
>>>> XMIResourceImpl(URI.createFileURI(" D:/workspaces/testingWorkbench/runtime-EclipseApplication/te stiingMM/model/CommitTest_PST_gen.testing "));
>>>> resource.getContents().add(pst);
>>>> try {
>>>> resource.save(null);
>>>> } catch (IOException e) {
>>>> e.printStackTrace();
>>>> }
>>>>
>>>> Nothing unusual, i think. So, these are my problems:
>>>>
>>>> 1. org.eclipse.emf.ecore.xmi.FeatureNotFoundException: Feature 'version'
>>>> not found.
>>>> (platform:/resource/testiingMM/model/CommitTest_PST_gen.test ing, 2, 326)
>>>>
>>>> 2. org.eclipse.emf.ecore.xmi.FeatureNotFoundException: Feature 'href' not
>>>> found. (platform:/resource/testiingMM/model/CommitTest_PST_gen.test ing,
>>>> 6, 139)
>>>>
>>>>
>>>>
>>> These sound like load problems and the code above is doing a save. I'd
>>> expect problems like the one above if the resource doing the loading isn't
>>> expecting XMI. Note that if you invoke "Generate Test Code" and look in
>>> the *.tests projects there's a generated XyzExample.java which shows a
>>> good example of how to load and save resources.
>>>
>>>> The related element in the XMI looks like:
>>>>
>>>> <ownedElements xsi:type="modelplex.testing.foundation:Property"
>>>> name="mesagge">
>>>>
>>>> <theType xsi:type="modelplex.testing.foundation:PrimitiveType"
>>>> href="TestingMMPrimitiveTypes.library.testing#//@ownedElements.0 "/>
>>>>
>>>> </ownedElements>
>>>>
>>>> It seems to me, like the theType element is contained by
>>>> message:Property, what isn't so.
>>>>
>>>> The manual created element looks like this:
>>>>
>>>> <ownedElements xsi:type="modelplex.testing.foundation:Property"
>>>> id="CommitTest_PST_structure_CommitRequest_file" name="rq_file"
>>>> theType="modelplex.testing.foundation:PrimitiveType
>>>> TestingMMPrimitiveTypes.library.testing#//@ownedElements.0"/ >
>>>>
>>>>
>>> If this is an XMI serialization, it's using different options. Note that
>>> the way you created the resource bypasses the option set in the resource
>>> factory.
>>>
>>>> How to get thinks working programmatically, like they would have been
>>>> created and crossed linked via "Load Ressource"?
>>>>
>>>>
>>> Probably the generated example will help.
>>>
>>>> Thanks at all
>>>>
>>>> Timothy
>>>>
>>>>
>>>>
>>>>
>>
>>
>>
>>
>

--------------000401020802050903040801
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Timothy,<br>
<br>
Yes, factories are a very important concept since this ensures that
when handling your type of resource, the right options and right choice
of resource implementation is consistently made.&nbsp; There are even
GenPackage options to switch between XMI and XML resources, but yes,
generally tailoring will be done by specializing with the
createResource method does in the factory.<br>
<br>
<br>
Timothy Marc wrote:
<blockquote cite="mid:g5nbmn$r4e$1@build.eclipse.org" type="cite">
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">
<meta content="MSHTML 6.00.2900.3354" name="GENERATOR">
<style></style>
<div><font face="Arial" size="2">Dear Ed,</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">thanks again, it works fine now. I
think i now get the ideas of all these Factories in EMF. So, if i want
the Editor to serialize my model as XMI, i have to change it in the
model-specific Factory,i.e. in the createResource method.</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">Thanks for your patience.</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">Timothy</font></div>
<blockquote dir="ltr"
style="border-left: 2px solid rgb(0, 0, 0); padding-right: 0px; padding-left: 5px; margin-left: 5px; margin-right: 0px;">
<div>"Ed Merks" &lt;<a moz-do-not-send="true"
href="mailto:Ed.Merks@gmail.com">Ed.Merks@gmail.com</a>&gt; schrieb im
Newsbeitrag <a moz-do-not-send="true"
href="news:g5n9u9$2n3$1@build.eclipse.org">news:g5n9u9$2n3$1@build.eclipse.org</a>...</div>
Timothy,<br>
<br>
Comments below.<br>
<br>
Timothy Marc wrote:
<blockquote cite="mid:g5n9b9$qtp$1@build.eclipse.org" type="cite">
<pre wrap="">Dear Ed,

sorry for mentioning imprecise code snippets. The exceptions, i mentioned,
are surely during the load operation in the generated Editor. I saved them
with the snippet i have shown (it is very close to the code in
XYZExample.java)</pre>
</blockquote>
It didn't look so close to me.<br>
<blockquote cite="mid:g5n9b9$qtp$1@build.eclipse.org" type="cite">
<pre wrap="">, but i can'topen it in the generated Editor. </pre>
</blockquote>
That makes it clear to me that they are using different serialization
approaches or significantly different options.&nbsp; Look carefully at the
resource factory being used to create the resource in each case.<br>
<blockquote cite="mid:g5n9b9$qtp$1@build.eclipse.org" type="cite">
<pre wrap="">I even try to
create not an XMI/XML Resource but a domain-specific one, which was
generated in the util-Package of my model. In my case its name is
TestingResourceImpl.
</pre>
</blockquote>
Again, be sure to look closely at the factory that creates this
implementation class.&nbsp; Be sure that in both cases the same factory is
being used for both load and save.<br>
<blockquote cite="mid:g5n9b9$qtp$1@build.eclipse.org" type="cite">
<pre wrap="">When i create a model by using the generated tree editor, the editor
serializes the model as what kind of resource? </pre>
</blockquote>
That depends on your registrations.&nbsp; If all goes well, I'd expect your
TestingResourceFactoryImpl's createResource to end up being called.<br>
<blockquote cite="mid:g5n9b9$qtp$1@build.eclipse.org" type="cite">
<pre wrap="">I'm wondering why the
type-element, i mentioned in the post before, is one hand an attribute of an
element (like i want it to be) and on the other hand, by programmatically
creating the same model, a contained element of that element?
</pre>
</blockquote>
An XMIResourceImpl will tend to serialize cross resource references
using &lt;owner&gt;&lt;feature-name href="reference"/&gt;&lt;/owner&gt;
but an XMLResourceImpl will use &lt;owner feature-name="reference"/&gt;.<br>
<blockquote cite="mid:g5n9b9$qtp$1@build.eclipse.org" type="cite">
<pre wrap="">Thx
-- Timothy


"Ed Merks" <a moz-do-not-send="true" class="moz-txt-link-rfc2396E"
href="mailto:Ed.Merks@gmail.com">&lt;Ed.Merks@gmail.com&gt;</a> schrieb im Newsbeitrag
<a moz-do-not-send="true" class="moz-txt-link-freetext"
href="news:g5l5pi$t20$1@build.eclipse.org">news:g5l5pi$t20$1@build.eclipse.org</a>...
</pre>
<blockquote type="cite">
<pre wrap="">Timothy,

Gosh but there are a lot of questions today. I hope I don't go insane.


Timothy Marc wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Hi all,

first, let me explain my problem.

I have created a model manually. In that model, i included another
resource with the "Load Resource"-functionality of the generated
EMF-Editor.

Now, i want to generate the same model programmatically, but i had some
problems with the serialization.

Here is my code, that writes out the model:

final XMIResource resource = new
XMIResourceImpl(URI.createFileURI(" D:/workspaces/testingWorkbench/runtime-EclipseApplication/te stiingMM/model/CommitTest_PST_gen.testing "));
resource.getContents().add(pst);
try {
resource.save(null);
} catch (IOException e) {
e.printStackTrace();
}

Nothing unusual, i think. So, these are my problems:

1. org.eclipse.emf.ecore.xmi.FeatureNotFoundException: Feature 'version'
not found.
(platform:/resource/testiingMM/model/CommitTest_PST_gen.test ing, 2, 326)

2. org.eclipse.emf.ecore.xmi.FeatureNotFoundException: Feature 'href' not
found. (platform:/resource/testiingMM/model/CommitTest_PST_gen.test ing,
6, 139)


</pre>
</blockquote>
<pre wrap="">These sound like load problems and the code above is doing a save. I'd
expect problems like the one above if the resource doing the loading isn't
expecting XMI. Note that if you invoke "Generate Test Code" and look in
the *.tests projects there's a generated XyzExample.java which shows a
good example of how to load and save resources.
</pre>
<blockquote type="cite">
<pre wrap="">The related element in the XMI looks like:

&lt;ownedElements xsi:type="modelplex.testing.foundation:Property"
name="mesagge"&gt;

&lt;theType xsi:type="modelplex.testing.foundation:PrimitiveType"
href=<a moz-do-not-send="true" class="moz-txt-link-rfc2396E"
href=" mailto:TestingMMPrimitiveTypes.library.testing#//@ownedEleme nts.0 ">"TestingMMPrimitiveTypes.library.testing#//@ownedElements.0 "</a>/&gt;

&lt;/ownedElements&gt;

It seems to me, like the theType element is contained by
message:Property, what isn't so.

The manual created element looks like this:

&lt;ownedElements xsi:type="modelplex.testing.foundation:Property"
id="CommitTest_PST_structure_CommitRequest_file" name="rq_file"
theType="modelplex.testing.foundation:PrimitiveType
<a moz-do-not-send="true" class="moz-txt-link-abbreviated"
href=" mailto:TestingMMPrimitiveTypes.library.testing#//@ownedEleme nts.0 ">TestingMMPrimitiveTypes.library.testing#//@ownedElements.0 </a>"/&gt;

</pre>
</blockquote>
<pre wrap="">If this is an XMI serialization, it's using different options. Note that
the way you created the resource bypasses the option set in the resource
factory.
</pre>
<blockquote type="cite">
<pre wrap="">How to get thinks working programmatically, like they would have been
created and crossed linked via "Load Ressource"?

</pre>
</blockquote>
<pre wrap="">Probably the generated example will help.
</pre>
<blockquote type="cite">
<pre wrap="">Thanks at all

Timothy



</pre>
</blockquote>
</blockquote>
<pre wrap=""><!---->


</pre>
</blockquote>
</blockquote>
</blockquote>
</body>
</html>

--------------000401020802050903040801--


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Save special chars ?
Next Topic:Re: [Teneo/Hibernate]Check for running DB
Goto Forum:
  


Current Time: Tue Apr 16 04:06:29 GMT 2024

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

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

Back to the top