Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » EMF Ecore output xmi, can have only text content element ?(How can i model my ecore file which to use only text element on xmi ecore output)
EMF Ecore output xmi, can have only text content element ? [message #1002405] Fri, 18 January 2013 14:17 Go to next message
serhat gezgin is currently offline serhat gezginFriend
Messages: 242
Registered: January 2013
Location: Izmir
Senior Member
my ecore model like (simplified);

<eClassifiers xsi:type="ecore:EClass" name="IClafer" eSuperTypes="#//IElement">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="isAbstract" lowerBound="1"
eType="ecore:EDataType ...XMLType#//Boolean"
unsettable="true">
</eStructuralFeatures>
</eClassifiers>

my dynamic instance from this model look like;

<?xml version="1.0" encoding="ASCII"?>
<ir:IModule>
<declaration
xsi:type="ir:IClafer">
<isAbstract
value="true"/>
</declaration>
</ir:IModule>

but i want this xmi file (isAbstract with only text element) like;

<?xml version="1.0" encoding="ASCII"?>
<ir:IModule>
<declaration
xsi:type="ir:IClafer">
<isAbstract>false<isAbstract>
</declaration>
</ir:IModule>

So how should I create my eCore file ? (i try all posibility but cant find how can i do)
Re: EMF Ecore output xmi, can have only text content element ? [message #1002480 is a reply to message #1002405] Fri, 18 January 2013 17:00 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 26278
Registered: July 2009
Senior Member
Serhat,

Comments below.

On 18/01/2013 4:49 PM, serhat gezgin wrote:
> my ecore model like (simplified);
>
> <eClassifiers xsi:type="ecore:EClass" name="IClafer"
> eSuperTypes="#//IElement">
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="isAbstract"
> lowerBound="1"
> eType="ecore:EDataType ...XMLType#//Boolean"
> unsettable="true">
> </eStructuralFeatures>
> </eClassifiers>
>
> my dynamic instance from this model look like;
>
> <?xml version="1.0" encoding="ASCII"?>
> <ir:IModule>
> <declaration
> xsi:type="ir:IClafer">
> <isAbstract
> value="true"/>
> </declaration>
> </ir:IModule>
I don't think EMF would produce such a serialization. Where's the XMI
declaration? The isAbstract feature would serialize as an attribute, by
default. You must be leaving some details out of your posting...
>
> but i want this xmi file (isAbstract with only text element) like;
>
> <?xml version="1.0" encoding="ASCII"?>
> <ir:IModule>
> <declaration
> xsi:type="ir:IClafer">
> <isAbstract>false<isAbstract>
> </declaration>
> </ir:IModule>
>
> So how should I create my eCore file ? (i try all posibility but cant
> find how can i do)
You can influence serialization using extended meta data annotations.
Try creating a schema that specifies the serialization you're expecting
(or look at the Library.xsd from the XML Schema tutorial) and look at
the EAnnotations in the Ecore model generated from it.
Re: EMF Ecore output xmi, can have only text content element ? [message #1003530 is a reply to message #1002480] Mon, 21 January 2013 12:59 Go to previous messageGo to next message
serhat gezgin is currently offline serhat gezginFriend
Messages: 242
Registered: January 2013
Location: Izmir
Senior Member
i already create this ecore from XSD file and XSD instance XML is like;

<?xml version="1.0" encoding="ASCII"?>
<ir:IModule>
<declaration
xsi:type="ir:IClafer">
<isAbstract>false<isAbstract>
</declaration>
</ir:IModule>

as expected for me.

But when i create dynamic instance (xmi) from ecore, <isAbstract> element now become an attribute. but why ? I need isAbstract as element

U can try too
(my xsd file attached)


  • Attachment: library.xsd
    (Size: 14.45KB, Downloaded 42 times)
Re: EMF Ecore output xmi, can have only text content element ? [message #1003551 is a reply to message #1003530] Mon, 21 January 2013 13:52 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 26278
Registered: July 2009
Senior Member
Serhat,

The wizard that creates a dynamic instance always creates a resource
that uses an XMI serialization. You shouldn't expect an XMI
serialization to conform to your schema. Even what you show below
doesn't conform to your schema; there's no global element called "IModule".

It's possible to work with dynamic models that conform to the schema,
but you'd need to use GenericXMLResourceFactoryImpl to create resources
for that purpose.

Why aren't you working with the generated model?


On 21/01/2013 1:59 PM, serhat gezgin wrote:
> i already create this ecore from XSD file and XSD instance XML is like;
>
> <?xml version="1.0" encoding="ASCII"?>
> <ir:IModule>
> <declaration
> xsi:type="ir:IClafer">
> <isAbstract>false<isAbstract>
> </declaration>
> </ir:IModule>
>
> as expected for me.
>
> But when i create dynamic instance (xmi) from ecore, <isAbstract> element now become an attribute. but why ? I need isAbstract as element
>
> U can try too
> (my xsd file attached)
>
>
>
Re: EMF Ecore output xmi, can have only text content element ? [message #1003571 is a reply to message #1003551] Mon, 21 January 2013 14:38 Go to previous messageGo to next message
serhat gezgin is currently offline serhat gezginFriend
Messages: 242
Registered: January 2013
Location: Izmir
Senior Member
ok but i worked with generated model.

i just write these above xmls as an example for the question.

What i have done ?

ir.xsd metamodel of ir.xml

ir.ecore metamodel of IModule.xmi (which created from IModele class with create dynamic instance method)

and when i look the IModule and ir.xml models they are not consistent with eachother.

so i think metamodels not consistent too.


(files attached)
  • Attachment: ir.xml
    (Size: 1.55KB, Downloaded 45 times)
  • Attachment: ir.xsd
    (Size: 10.63KB, Downloaded 45 times)
  • Attachment: ir.ecore
    (Size: 37.30KB, Downloaded 50 times)
  • Attachment: ir.ecorediag
    (Size: 103.76KB, Downloaded 48 times)
  • Attachment: IModule.xmi
    (Size: 0.35KB, Downloaded 51 times)

[Updated on: Mon, 21 January 2013 14:44]

Report message to a moderator

Re: EMF Ecore output xmi, can have only text content element ? [message #1003579 is a reply to message #1003571] Mon, 21 January 2013 14:52 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 26278
Registered: July 2009
Senior Member
Serhat,

Comments below.

On 21/01/2013 3:38 PM, serhat gezgin wrote:
> ok but i worked with generated model.
Yes.
>
> i just write these above xmls as an example for the question.
>
> What i have done ?
?
>
> ir.xsd metamodel of ir.xml
Well, not of the one you showed...
>
> ir.ecore metamodel of IModule.xmi (which created from IModele class with create dynamic instance method)
>
> and when i look the IModule and ir.xml models they are not consistent with eachother.
Any number of serializations are possible. You can use an XMI
serialization and a resource created by XMIResourceFactoryImpl can read
and write that; that's what the reflective editor uses. Or you can use
an XML serialization that conforms to your XML Schema; resources created
by your generated resource factory implementation or by
GenericResourceFactoryImpl can read and write that...
>
> so i think metamodels not consistent too.
Why do you think that?
>
>
> (files attached)
What do you want me to do with those?
Re: EMF Ecore output xmi, can have only text content element ? [message #1003584 is a reply to message #1003579] Mon, 21 January 2013 15:08 Go to previous messageGo to next message
serhat gezgin is currently offline serhat gezginFriend
Messages: 242
Registered: January 2013
Location: Izmir
Senior Member
i just say that, java annotations does not work as i expected
Re: EMF Ecore output xmi, can have only text content element ? [message #1003605 is a reply to message #1003584] Mon, 21 January 2013 15:42 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 26278
Registered: July 2009
Senior Member
Java annotations?

Note that extended meta data annotations in the model are only respected
when OPTION_EXTENDED_META_DATA is used as a load or save option in the
resource implementation. XMIResourceFactoryImpl doesn't do that by
default. Your generated resource factory does.


On 21/01/2013 4:08 PM, serhat gezgin wrote:
> i just say that, java annotations does not work as i expected
Re: EMF Ecore output xmi, can have only text content element ? [message #1003945 is a reply to message #1003605] Tue, 22 January 2013 09:49 Go to previous message
serhat gezgin is currently offline serhat gezginFriend
Messages: 242
Registered: January 2013
Location: Izmir
Senior Member
Ahh i understand now. I was forced to understanding u because of my little english Smile

When i run application.editor and create ir Model, i have what i expect

But any way i dont understand why dynamic instance not give that. i think i must re read your replies.

Thanks for help Smile

regards

Serhat
Previous Topic:Manually creating and firing events from inside another listener
Next Topic:[xcore/xbase] Referencing operation parameters from inside lambda expressions
Goto Forum:
  


Current Time: Thu Dec 18 02:31:55 GMT 2014

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

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