Home » Modeling » Modeling (top-level project) » serialize ecore references into container
|
Re: serialize ecore references into container [message #640140 is a reply to message #640132] |
Fri, 19 November 2010 09:57 |
Philip Langer Messages: 31 Registered: July 2009 |
Member |
|
|
Hi,
please see below...
On 2010-11-19 10:25, Florian Marienfeld wrote:
> Hi,
>
> suppose I have this metamodel:
>
> class Chair has a reference named "parts" of type "Part". Part is
> superclass to classes Leg and Arm.
>
> by default a model instance gets serialized to this:
>
> <chair:Chair xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:chair="chair.de">
> <parts xsi:type="chair:Arm"/>
> <parts xsi:type="chair:Leg"/>
> </chair:Chair>
This XML format is conforming to the XMI standard. In XMI you always have
<$referenceName xsi:type="$type" ($attributes)*>...</$referenceName>
>
> What I would like is:
>
> <Chair>
> <Parts>
> <Arm/>
> <Leg/>
> </Parts>
> </Chair>
>
> What is the way to go?
If you want to change that format without touching the metamodel, I
guess, you would have to write your own Resource/ResourceFactory
implementation and register it before serializing your model rather than
using XMIResources.
But you could also write an XML schema according to your needs and
generate the corresponding ecore model and then use the
GenericXMLResourceFactoryImpl as, I guess, Ed suggested (cf. end of
article [1]).
>
> Thanks, Ed, for pointing me at your article on substitution groups
> (http://ed-merks.blogspot.com/2007/12/winters-icy-grip.html) .
> However, that does not give me the container tag, in my case <parts>, right?
>
> Best regards, thanks in advance,
>
> FLO
>
HTH,
Philip
[1] http://www.devx.com/Java/Article/29093/1954
|
|
|
Re: serialize ecore references into container [message #640194 is a reply to message #640132] |
Fri, 19 November 2010 14:21 |
Ed Merks Messages: 33107 Registered: July 2009 |
Senior Member |
|
|
Florian,
I've not found the time to complete the work for
https://bugs.eclipse.org/bugs/show_bug.cgi?id=201662
Florian Marienfeld wrote:
> Hi,
>
> suppose I have this metamodel:
>
> class Chair has a reference named "parts" of type "Part". Part is
> superclass to classes Leg and Arm.
>
> by default a model instance gets serialized to this:
>
> <chair:Chair xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:chair="chair.de">
> <parts xsi:type="chair:Arm"/>
> <parts xsi:type="chair:Leg"/>
> </chair:Chair>
>
> What I would like is:
>
> <Chair>
> <Parts>
> <Arm/>
> <Leg/>
> </Parts>
> </Chair>
>
> What is the way to go?
>
> Thanks, Ed, for pointing me at your article on substitution groups
> (http://ed-merks.blogspot.com/2007/12/winters-icy-grip.html) .
> However, that does not give me the container tag, in my case <parts>, right?
>
> Best regards, thanks in advance,
>
> FLO
>
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Goto Forum:
Current Time: Tue Mar 19 06:02:17 GMT 2024
Powered by FUDForum. Page generated in 0.02627 seconds
|