|
Re: [EMF] XML Serialization sequentially [message #1225249 is a reply to message #1225141] |
Sun, 29 December 2013 06:41 |
Ed Merks Messages: 33142 Registered: July 2009 |
Senior Member |
|
|
Benjamin,
Comments below.
On 28/12/2013 11:05 PM, Benjamin M. wrote:
> Hello EMF Community,
>
> I tried to search for similiar questions on the forum - but
> surprisingly I couldnt find any. (If I was just unable to figure out
> the right keywords, I apologize)
>
> My goal is to serialize an Ecore-Model instance sequentially. I
> created my Ecore-Model out of a bigger XSD (around 2500 lines) and
> this results ofc into different java classes with relational
> dependencies. To avoid representing the whole model into the memory, I
> want to serialize each of these java classes step by step.
How many in-memory instances are we talking about? How much memory do
they consume? Do you plan to compose these pieces into a single document?
> But this results naturally in invalid opening and enclosing XML-Tags,
> since each java class is serialized as if it is an own XML document.
If the schema only allows certain root elements (has only certain global
element declarations) only those can be directly serialized in a way
that conforms to the schema. A document root is generally needed as
the root object in the resource in order to specify the namespace/name
of the root element. You can use
org.eclipse.emf.ecore.util.ExtendedMetaData.demandFeature(String,
String, boolean) to create an element with the desired namespace/name;
the getEContainingClass of that element will be a document root class
and you can make your object a child of that feature of and instance of
that document root class and serialize that document root to produce a
serialization with the desired root element.
This article is likely to be helpful:
http://www.theserverside.com/news/1364302/Binding-XML-to-Java
>
> So: Is there any possibility with EMF to achieve this?
>
> Any links or hints are appreciated!
>
> Cheers,
> Ben
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Re: [EMF] XML Serialization sequentially [message #1225268 is a reply to message #1225249] |
Sun, 29 December 2013 08:14 |
Benjamin M. Messages: 13 Registered: September 2012 |
Junior Member |
|
|
Hello Ed,
Ed Merks wrote on Sun, 29 December 2013 01:41Benjamin,
How many in-memory instances are we talking about? How much memory do
they consume??
Its actually a requirement for my project. I know its a killer argument, but thats how it is. If you are rly interested in hearing more details, I will explain it in my next post.
Ed Merks wrote on Sun, 29 December 2013 01:41
Do you plan to compose these pieces into a single document?
Yes, my goal is to get the same result as if I filled up all the relational dependencies from the top (rootDocument) till the end, having one single XML document at the end.
Ed Merks wrote on Sun, 29 December 2013 01:41
If the schema only allows certain root elements (has only certain global
element declarations) only those can be directly serialized in a way
that conforms to the schema. A document root is generally needed as
the root object in the resource in order to specify the namespace/name
of the root element. You can use
org.eclipse.emf.ecore.util.ExtendedMetaData.demandFeature(String,
String, boolean) to create an element with the desired namespace/name;
the getEContainingClass of that element will be a document root class
and you can make your object a child of that feature of and instance of
that document root class and serialize that document root to produce a
serialization with the desired root element.
This article is likely to be helpful:
http://www.theserverside.com/news/1364302/Binding-XML-to-Java
Thanks for the late christmas gift, Ed. I will try it out. First step would be to override the automatically created namespace/name of XML-Elements (nested Java classes/document root classes) for the serialization with your given approach. The article is indeed helpful.
To clearify a bit the xml schema structure: At the beginning theres a whole block of meta data which I can serialize directly. After that its like this: A contains B, B contains C, C contains D1,D2...Dn. Thats why the enclosing xml tags of A,B,C are invalid.
Cheers,
Ben
[Updated on: Sun, 29 December 2013 08:33] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.04277 seconds