Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » When saving a resource how to create text nodes for resource attributes?(I want to be able to create a text node for a node attribute)
When saving a resource how to create text nodes for resource attributes? [message #871027] Thu, 10 May 2012 14:51 Go to next message
Thiago Santos is currently offline Thiago SantosFriend
Messages: 2
Registered: May 2012
Junior Member
Hello there,

I'm fairly recent to EMF development so this question might be trivial to answer but i haven't found any information that could allow me to resolve tbis.

I declared a .ecore file named Test.ecore

In it i defined a EClass named 'Person' with one EAttribute named 'personName' of type EString. Now when saving the Person resource i imagine i will get something like:

<?xml version="1.0" encoding="UTF-8"?>

<Test:Person xmi:version="2.0" personName="Thiago"/>


How can i make it so that when saving the resource, the attribute personName is a Text Node instead of a attribute of Person? Something like this:


<?xml version="1.0" encoding="UTF-8"?>
<Test:Person xmi:version="2.0">
       <personName>Thiago</personName>
</Test:Person>
Re: When saving a resource how to create text nodes for resource attributes? [message #871034 is a reply to message #871027] Thu, 10 May 2012 15:09 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Thiago,<br>
<br>
Comments below.<br>
<br>
On 10/05/2012 4:51 PM, Thiago Santos wrote:
<blockquote cite="mid:jogkkl$60u$1@xxxxxxxxe.org" type="cite">Hello
there,
<br>
<br>
I'm fairly recent to EMF development so this question might be
trivial to answer but i haven't found any information that could
allow me to resolve tbis.
<br>
<br>
I declared a .ecore file named Test.ecore
<br>
<br>
In it i defined a EClass named 'Person' with one EAttribute named
'personName' of type EString. Now when saving the Person resource
i imagine i will get something like:
<br>
<br>
<br>
&lt;?xml version="1.0" encoding="UTF-8"?&gt;
<br>
<br>
&lt;Test:Person xmi:version="2.0" personName="Thiago"/&gt;
<br>
<br>
<br>
How can i make it so that when saving the resource, the attribute
personName is a Text Node instead of a attribute of Person?
Something like this:
<br>
<br>
<br>
<br>
&lt;?xml version="1.0" encoding="UTF-8"?&gt;
<br>
&lt;Test:Person xmi:version="2.0"&gt;
<br>
      &lt;personName&gt;Thiago&lt;/personName&gt;
<br>
&lt;/Test:Person&gt;
<br>
<br>
</blockquote>
You'll need to add extended meta data annotation to specify you want
it serialized as an element <a
href="http://www.eclipse.org/modeling/emf/docs/overviews/XMLSchemaToEcoreMapping.pdf">http://www.eclipse.org/modeling/emf/docs/overviews/XMLSchemaToEcoreMapping.pdf
</a>and use OPTION_EXTENDED_META_DATA as a save option so the
annotations are respected.<br>
</body>
</html>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: When saving a resource how to create text nodes for resource attributes? [message #871037 is a reply to message #871034] Thu, 10 May 2012 15:28 Go to previous message
Thiago Santos is currently offline Thiago SantosFriend
Messages: 2
Registered: May 2012
Junior Member
Thanks Ed. I'll take a look into it.
Previous Topic:Working with fragment queries
Next Topic:EMF extending existing model
Goto Forum:
  


Current Time: Fri Apr 26 12:02:03 GMT 2024

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

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

Back to the top