Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Customize XML serialization using ERefence Etype instead of name(Customize XML serialization)
Customize XML serialization using ERefence Etype instead of name [message #1276709] Mon, 24 March 2014 23:43 Go to next message
Agustin Vosou is currently offline Agustin VosouFriend
Messages: 5
Registered: March 2014
Junior Member
Hi everyone,

After days and days of looking for a solution I decided to post my question in this forum.

I have a very simple Ecore file for a Filesystem and I have created a diagram using GMF, but I am having a problem with the generated diagram's XML.
The problem is that the XML nodes inside de diagram are being generated using the EReference "name" attribute instead of the "EType" attribute.

E.G. I'd like to change <files> to <File>; and <folders> to <Folder> in the following example.

Ecore:
File
  name: EType EString
Folder
  name: EType EString
  folders: EType Folder
  files: EType File
Filesytem
  folders: EType Folder, containment: true
  files: EType File, containment: true


Diagram:
Filesystem:
  folders: Folder1,Folder2
  files: File1
Folder:
  name: Folder1
  folders: Folder2
  files: File1
Folder:
  name: Folder2
  folders: -
  files: -
File:
  name: File1


Diagram's XML

<com.example.filesystem:Filesystem xmi:id="_VFkHMLCAEeOdou7_dXIPjg">
  <folders xmi:type="com.example.filesystem:Folder" xmi:id="_WWim4LCAEeOdou7_dXIPjg" name="Folder1" folders="_XGFNcLCAEeOdou7_dXIPjg" files="_Vt-LALCAEeOdou7_dXIPjg"/>
  <folders xmi:type="com.example.filesystem:Folder" xmi:id="_XGFNcLCAEeOdou7_dXIPjg" name="Folder2"/>
  <files xmi:type="com.example.filesystem:File" xmi:id="_Vt-LALCAEeOdou7_dXIPjg" name="File1"/>
</com.example.filesystem:Filesystem>


Expected diagram's XML

<com.example.filesystem:Filesystem xmi:id="_VFkHMLCAEeOdou7_dXIPjg">
  <Folder xmi:type="com.example.filesystem:Folder" xmi:id="_WWim4LCAEeOdou7_dXIPjg" name="Folder1" folders="_XGFNcLCAEeOdou7_dXIPjg" files="_Vt-LALCAEeOdou7_dXIPjg"/>
  <Folder xmi:type="com.example.filesystem:Folder" xmi:id="_XGFNcLCAEeOdou7_dXIPjg" name="Folder2"/>
  <File xmi:type="com.example.filesystem:File" xmi:id="_Vt-LALCAEeOdou7_dXIPjg" name="File1"/>
</com.example.filesystem:Filesystem>


Is there any way to do it but not having to change the references name attributes?

Thank you,
Agustin
Re: Customize XML serialization using ERefence Etype instead of name [message #1276802 is a reply to message #1276709] Tue, 25 March 2014 03:17 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 31020
Registered: July 2009
Senior Member
Agustin,

Nested elements always use feature names, not type names. You might
want to look at
http://ed-merks.blogspot.ca/2007/12/winters-icy-grip.html if you are
hung up on the serialization format.

On 24/03/2014 7:58 PM, Agustin Vosou wrote:
> Hi everyone,
>
> After days and days of looking for a solution I decided to post my
> question in this forum.
>
> I have a very simple Ecore file for a Filesystem and I have created a
> diagram using GMF, but I am having a problem with the generated
> diagram's XML.
> The problem is that the XML nodes inside de diagram are being
> generated using the EReference "name" attribute instead of the "EType"
> attribute.
>
> E.G. I'd like to change <files> to <File>; and <folders> to <Folder>
> in the following example.
>
> Ecore:
>
> File
> name: EType EString
> Folder
> name: EType EString
> folders: EType Folder
> files: EType File
> Filesytem
> folders: EType Folder, containment: true
> files: EType File, containment: true
>
>
> Diagram:
>
> Filesystem:
> folders: Folder1,Folder2
> files: File1
> Folder:
> name: Folder1
> folders: Folder2
> files: File1
> Folder:
> name: Folder2
> folders: -
> files: -
> File:
> name: File1
>
>
> Diagram's XML
>
>
> <com.example.filesystem:Filesystem xmi:id="_VFkHMLCAEeOdou7_dXIPjg">
> <folders xmi:type="com.example.filesystem:Folder"
> xmi:id="_WWim4LCAEeOdou7_dXIPjg" name="Folder1"
> folders="_XGFNcLCAEeOdou7_dXIPjg" files="_Vt-LALCAEeOdou7_dXIPjg"/>
> <folders xmi:type="com.example.filesystem:Folder"
> xmi:id="_XGFNcLCAEeOdou7_dXIPjg" name="Folder2"/>
> <files xmi:type="com.example.filesystem:File"
> xmi:id="_Vt-LALCAEeOdou7_dXIPjg" name="File1"/>
> </com.example.filesystem:Filesystem>
>
>
> Expected diagram's XML
>
>
> <com.example.filesystem:Filesystem xmi:id="_VFkHMLCAEeOdou7_dXIPjg">
> <Folder xmi:type="com.example.filesystem:Folder"
> xmi:id="_WWim4LCAEeOdou7_dXIPjg" name="Folder1"
> folders="_XGFNcLCAEeOdou7_dXIPjg" files="_Vt-LALCAEeOdou7_dXIPjg"/>
> <Folder xmi:type="com.example.filesystem:Folder"
> xmi:id="_XGFNcLCAEeOdou7_dXIPjg" name="Folder2"/>
> <File xmi:type="com.example.filesystem:File"
> xmi:id="_Vt-LALCAEeOdou7_dXIPjg" name="File1"/>
> </com.example.filesystem:Filesystem>
>
>
> Is there any way to do it but not having to change the references name
> attributes?
>
> Thank you,
> Agustin
Re: Customize XML serialization using ERefence Etype instead of name [message #1277438 is a reply to message #1276802] Wed, 26 March 2014 01:27 Go to previous message
Agustin Vosou is currently offline Agustin VosouFriend
Messages: 5
Registered: March 2014
Junior Member
Thank you Ed, I am going to try that to customize the serialization.
Previous Topic:Synch EMF and GMF
Next Topic:Custom Figure not showing in generated editor
Goto Forum:
  


Current Time: Fri Apr 03 02:07:29 GMT 2020

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

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

Back to the top