Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Binding XML to java: serialization of mixed content cdata, text and comments
Binding XML to java: serialization of mixed content cdata, text and comments [message #660414] Fri, 18 March 2011 11:09 Go to next message
keller_jens is currently offline keller_jens
Messages: 21
Registered: March 2010
Location: Germany
Junior Member
Hi,
I've read the tutorial
http://www.theserverside.com/news/1364302/Binding-XML-to-Jav a

downloaded the source code and imported it into my workspace (I used Eclipse 3.4 for that as I got compile errors when using a higher Eclipse version).

Then I generated the model, edit and editor layer and launched another Eclipse application to see the example running.

I've then tried to imitate the structure of the example file data/EMFDOMTreeNodeWithReferences.xml using the generated wizard and editor.
The result looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<tree:DocumentRoot xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:tree="http://www.eclipse.org/emf/example/dom/Tree">
  <rootNode label="root" references="root">
    <childNodes label="text" references="root">
text    </childNodes>
    <childNodes label="comment" references="root">
<!--comment-->    </childNodes>
    <childNodes label="cdata" references="root">
<![CDATA[<cdata>]]>    </childNodes>
  </rootNode>
</tree:DocumentRoot>


I've also executed the TreeExample as a simple Java Application. The serialization looks then like this:

<?xml version="1.0" encoding="ASCII"?>
<tree:rootNode xmlns:tree="http://www.eclipse.org/emf/example/dom/Tree" label="root" references="#root EMFDOMTreeNodeWithReferences.xml#root">
  <tree:childNode label="text" references="#root EMFDOMTreeNodeWithReferences.xml#text">text</tree:childNode>
  <tree:childNode label="comment" references="#root EMFDOMTreeNodeWithReferences.xml#comment"><!--comment--></tree:childNode>
  <tree:childNode label="cdata" references="#root EMFDOMTreeNodeWithReferences.xml#cdata"><![CDATA[<cdata>]]></tree:childNode>
</tree:rootNode>


a) the formatting in the output from the TreeExample looks much better. In the output from the plugin wizard/editor, especially the text has whitespace which is not desired

b) in the serialization from the plugin wizard/editor the root tag is <tree:DocumentRoot> while in the serialization from the TreeExample the root tag is <tree:rootNode>. The latter one is in my opinion correct. What is causing the different serialization?

c) also in the TreeExample the model that is loaded from the XML contains all elements, including text, cdata and comment. This is not the case for the model that is loaded by the plugin editor. I've debugged into the createModel() method from the generated TreeEditor.java and can see that the "mixed" field of the child nodes is null. So text, cdata and comment are missing in the model, hence also not visible in the editor. After I apply some minor change in the editor and save, they are consequently also missing in the serialization. What is the reason for this?

Best regards
Jens
Re: Binding XML to java: serialization of mixed content cdata, text and comments [message #660465 is a reply to message #660414] Fri, 18 March 2011 14:20 Go to previous message
Ed Merks is currently offline Ed Merks
Messages: 26044
Registered: July 2009
Senior Member
Jens,

Comments below.

Jens Keller wrote:
> Hi,
> I've read the tutorial
> http://www.theserverside.com/news/1364302/Binding-XML-to-Jav a
>
> downloaded the source code and imported it into my workspace (I used
> Eclipse 3.4 for that as I got compile errors when using a higher
> Eclipse version).
>
> Then I generated the model, edit and editor layer and launched another
> Eclipse application to see the example running.
>
> I've then tried to imitate the structure of the example file
> data/EMFDOMTreeNodeWithReferences.xml using the generated wizard and
> editor. The result looks like this:
>
>
> <?xml version="1.0" encoding="UTF-8"?>
> <tree:DocumentRoot xmi:version="2.0"
> xmlns:xmi="http://www.omg.org/XMI"
> xmlns:tree="http://www.eclipse.org/emf/example/dom/Tree">
> <rootNode label="root" references="root">
> <childNodes label="text" references="root">
> text </childNodes>
> <childNodes label="comment" references="root">
> <!--comment--> </childNodes>
> <childNodes label="cdata" references="root">
> <![CDATA[<cdata>]]> </childNodes>
> </rootNode>
> </tree:DocumentRoot>
An XMI serialization. Likely there's a conflicting registration for
"xml" such that your resource factory isn't being used.
>
>
> I've also executed the TreeExample as a simple Java Application. The
> serialization looks then like this:
>
>
> <?xml version="1.0" encoding="ASCII"?>
> <tree:rootNode
> xmlns:tree="http://www.eclipse.org/emf/example/dom/Tree" label="root"
> references="#root EMFDOMTreeNodeWithReferences.xml#root">
> <tree:childNode label="text" references="#root
> EMFDOMTreeNodeWithReferences.xml#text">text</tree:childNode >
> <tree:childNode label="comment" references="#root
> EMFDOMTreeNodeWithReferences.xml#comment"><!--comment--></tree:childNode >
> <tree:childNode label="cdata" references="#root
> EMFDOMTreeNodeWithReferences.xml#cdata"><![CDATA[<cdata>]] ></tree:childNode>
>
> </tree:rootNode>
>
>
> a) the formatting in the output from the TreeExample looks much
> better. In the output from the plugin wizard/editor, especially the
> text has whitespace which is not desired
Nor is the XMI.
>
> b) in the serialization from the plugin wizard/editor the root tag is
> <tree:DocumentRoot> while in the serialization from the TreeExample
> the root tag is <tree:rootNode>. The latter one is in my opinion
> correct. What is causing the different serialization?
The resource implementation and associated options as determined by the
factory used to create the resource.
>
> c) also in the TreeExample the model that is loaded from the XML
> contains all elements, including text, cdata and comment. This is not
> the case for the model that is loaded by the plugin editor. I've
> debugged into the createModel() method from the generated
> TreeEditor.java and can see that the "mixed" field of the child nodes
> is null. So text, cdata and comment are missing in the model, hence
> also not visible in the editor. After I apply some minor change in the
> editor and save, they are consequently also missing in the
> serialization. What is the reason for this?
Same as above.
>
> Best regards
> Jens
Previous Topic:Proxy Resolution Problem
Next Topic:GSoC 2011 Ideas for EMF
Goto Forum:
  


Current Time: Tue Sep 16 07:43:33 GMT 2014

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

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