EMF serialize custom xml [message #498520] |
Tue, 17 November 2009 10:41 |
robin Missing name Messages: 16 Registered: November 2009 |
Junior Member |
|
|
hi,master,
I come from China,I like emf.
I create Ecore file and define my model.
Control1 Control2
| |
| |
V V
ControlObject
ControlObject is parent class and Control1 and Control2 is ControlObject's subclass.
In Container the ControlObject is EReference.
In my tree editor I create Control1 and Control2 in Container node and save.
The xml is:
<Container>
<ControlObject xsi:type="Control1"/>
<ControlObject xsi:type="Control2"/>
</Container>
I want to serialize:
<Container>
<Control1/>
<Control2/>
</Container>
what can I do?
Thanks.
[Updated on: Tue, 17 November 2009 13:43] Report message to a moderator
|
|
|
Re: EMF serialize cutomer xml [message #498573 is a reply to message #498520] |
Tue, 17 November 2009 14:46 |
Ed Merks Messages: 33142 Registered: July 2009 |
Senior Member |
|
|
This is a multi-part message in MIME format.
--------------090304060105050700010303
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Robin,
Comments below.
robin wrote:
> hi,master,
> I come from China,I like emf.
>
> I create Ecore file and define my model.
> Control1 Control2
> | |
> | |
> V V
> ControlObject
>
> ControlObject is parent
super class/type
> class and Control1 and Control2 is ControlObject's subclass.
>
> In Container the ControlObject is EReference.
>
> In my tree editor I create Control1 and Control2 in Container node and
> save.
>
> The xml is:
> <Container>
> <ControlObject xsi:type="Control1"/>
> <ControlObject xsi:type="Control2"/>
> </Container>
> I want to serialize:
> <Container>
> <Control1/>
> <Control2/>
> </Container>
>
> what can I do?
Serialization always uses the names of features, not the names of types,
except for the root element of an XMI serialization. If you defined the
model with XML Schema, you could make use of element substitution
groups. This blog has some details:
<http://ed-merks.blogspot.com/2007/12/winters-icy-grip.html>
http://ed-merks.blogspot.com/2007/12/winters-icy-grip.html
> Thanks.
>
--------------090304060105050700010303
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Robin,<br>
<br>
Comments below.<br>
<br>
robin wrote:
<blockquote cite="mid:hdtukc$2bj$1@build.eclipse.org" type="cite">hi,master,
<br>
I come from China,I like emf.
<br>
<br>
I create Ecore file and define my model.
<br>
Control1 Control2
<br>
| |
<br>
| |
<br>
V V
<br>
ControlObject
<br>
<br>
ControlObject is parent </blockquote>
super class/type<br>
<blockquote cite="mid:hdtukc$2bj$1@build.eclipse.org" type="cite">class
and Control1 and Control2 is ControlObject's subclass.
<br>
<br>
In Container the ControlObject is EReference.
<br>
<br>
In my tree editor I create Control1 and Control2 in Container node and
save.
<br>
<br>
The xml is:
<br>
<Container>
<br>
<ControlObject xsi:type="Control1"/>
<br>
<ControlObject xsi:type="Control2"/>
<br>
</Container>
<br>
I want to serialize:
<br>
<Container>
<br>
<Control1/>
<br>
<Control2/>
<br>
</Container>
<br>
<br>
what can I do?
<br>
</blockquote>
Serialization always uses the names of features, not the names of
types, except for the root element of an XMI serialization. If you
defined the model with XML Schema, you could make use of element
substitution groups. This blog has some details:<a
href="http://ed-merks.blogspot.com/2007/12/winters-icy-grip.html"><br>
</a>
<blockquote><a
href="http://ed-merks.blogspot.com/2007/12/winters-icy-grip.html">http://ed-merks.blogspot.com/2007/12/winters-icy-grip.html</a><br>
</blockquote>
<br>
<blockquote cite="mid:hdtukc$2bj$1@build.eclipse.org" type="cite">Thanks.
<br>
<br>
</blockquote>
</body>
</html>
--------------090304060105050700010303--
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
|
|
Re: EMF serialize custom xml [message #510913 is a reply to message #498520] |
Fri, 29 January 2010 07:21 |
robin Missing name Messages: 16 Registered: November 2009 |
Junior Member |
|
|
Thanks,I have been understand meta data EAnnotations.
But my model info exist in a xml file.
....
<Rule name="View" ></Rule>
<Rule name="Button"></Rule>
<Rule name="HtmlContainer"></Rule>
..
I parse this xml file and Create my emf model
ePackage = ecoreFactory.createEPackage();
ePackage.setName(PACKAGE_NAME);
ePackage.setNsURI(NS_URI);
parsexml()
for(xmlobject) {
createEClasses()
addAttributes()
addReference()
}
EList classifiers = ePackage.getEClassifiers();
addClassifier(classifiers, eClasses);
In addReference() I add Button and HtmlContainer object.
So I create My editor include TreeViewer.
This TreeViewer's root is View.
I add Button and HtmlContainer. But there can't transposition
+View
--Button
--Button
--HtmlContainer
The Button can't move down the HtmlContainer.
How can I create my model so that the childNode can be moved random?
+View
--Button
--HtmlContainer
--Button
[Updated on: Fri, 29 January 2010 07:41] Report message to a moderator
|
|
|
|
|
|
|
|
|
|
|
Re: EMF serialize custom xml [message #512196 is a reply to message #512136] |
Thu, 04 February 2010 11:23 |
Ed Merks Messages: 33142 Registered: July 2009 |
Senior Member |
|
|
Robin,
For what you've described, you'd not need to specialize any of these
things. There's really no significant body of documentation for these
low level implementation classes so you're best to use the debugger to
analyze the dynamic behavior of the source in action.
robin wrote:
> Hi,ed
> Thanks for your help.I debug my code.I change my model and override
> XMLResourceImpl,XMLSaveImpl,XMLLoadImpl and
> SAXXMLHandler,XMLHelperImpl for my model.
> So I succeed. :d But I can't find more specifically knowledge about
> xmlload xmlsave,xmlhandler.
> Can you give some suggestion for some example?
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Powered by
FUDForum. Page generated in 0.04582 seconds