|
Re: Serializing EMF Model with XML - Top Element [message #429766 is a reply to message #429722] |
Thu, 30 April 2009 17:26 |
Ed Merks Messages: 33142 Registered: July 2009 |
Senior Member |
|
|
Christoph,
Comments below.
Christoph Mayerhofer wrote:
> Hi!
>
> Today I tried to serialize my EMF Model to XML. I found out that the
> XMLSaveImpl class (which does the work of serialization) writes only
> the first object from the XMLResource' contents.
>
> protected Object writeTopObjects(List<? extends EObject> contents)
> {
> return writeTopObject(contents.get(0));
> }
>
> If I add several objects to the XMLResource' contents, only the first
> object is serialized.
>
> Is there a best practice how to add a top level object, or do I have
> to create a root object in my model?
You can use an XMIResource to save multiple roots; it will inject a
"fake" XMI root element to hold the contents. In general of course, XML
only allows one root element, so unless you're happy with an XMI
serialization, yes you'll have to define a root object to hold the
multiple children...
>
> Regards,
> Christoph
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Powered by
FUDForum. Page generated in 0.02833 seconds