Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » EMF editor for customized XML output
icon5.gif  EMF editor for customized XML output [message #517212] Fri, 26 February 2010 15:39 Go to next message
Nirmal SasidharanFriend
Messages: 120
Registered: July 2009
Location: Germany
Senior Member
Hello,

I have a metamodel in Enterprise Architect which I managed to convert into EMF UML2 (to bring it to the eclipse world). I need to build a EMF based editor to read and write a model based on this metamodel. The easiest way, I guess, would be to create a Ecore/Genmodel model out of the UML2 model I have. The provider of the original EA metamodel also supplies an XSD (which is similiar to the metamodel, but not completely. For example, it has wrapper elements to handle multiplicity etc.). What would be the right approach to develop an editor to read and write input based on the XSD and store it based in the metamodel mentioned earlier?

Can the default XML resource implementation be used to read the XML input and transform it to make it compatible with the metamodel or would be it easier to use an XML parser to read the input and create a model directly?

Regards,
Nirmal

[Updated on: Fri, 26 February 2010 15:40]

Report message to a moderator

Re: EMF editor for customized XML output [message #517240 is a reply to message #517212] Fri, 26 February 2010 16:23 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Nirmal,

Comments below.


Nirmal Sasidharan wrote:
> Hello,
>
> I have a metamodel in Enterprise Architect which I managed to convert
> into EMF UML2 (to bring it to the eclipse world). I need to build a
> EMF based editor to read and write a model based on this metamodel.
> The easiest way, I guess, would be to create a Ecore/Genmodel model
> out of the UML2 model I have. The provider of the original EA
> metamodel also supplies an XSD (which is similiar to the metamodel,
> but not completely. For example, it has wrapper elements to handle
> multiplicity etc.). What would be the right approach to develop an
> editor to read and write input based on the XSD and store it based in
> the metamodel mentioned earlier?
You can produce an Ecore model either from UML or from XSD. If you do
it from XSD, then serialization will conform to the XSD. If you do it
from UML, it will serialize as XMI by default. You can use extended
meta data annotations in the Ecore model to guide the element and
attribute names used in the XML, and even whether an element or an
attribute is used, but if the serialization has element nesting levels
that don't correspond to objects in the actual Ecore model, it gets far
more difficult.
> Can the default XML resource implementation be used to read the XML
> input and transform it to make it compatible with the metamodel or
> would be it easier to use an XML parser to read the input and create a
> model directly?
I suppose one could even have a model for each and do a transformation
step. Could you be more specific about what you mean by wrapper elements?
>
> Regards,
> Nirmal


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: EMF editor for customized XML output [message #518807 is a reply to message #517240] Fri, 05 March 2010 05:54 Go to previous messageGo to next message
Nirmal SasidharanFriend
Messages: 120
Registered: July 2009
Location: Germany
Senior Member
Hello Ed,

Thanks a lot for your reply.

I am thinking of using ecore2xml here, as the rules for my XML generation from the meta-model are straightforward. For example, all CamelCased model elements names are written out in uppercase with a hyphen in between (PurchaseOrder as PURCHASE-ORDER). There are some more rules on attribute and reference handling, but they are generic too. I don't want to declaratively create mappings for my model elements, but rather inspect the meta-model at runtime and create these rules. Do you think this could be managed by using ecore2xml programmatically rather than declaratively?

Would this be the right approach or are there some other hooks in XMLResourceImpl with which the output could be customized programmatically?

Thanks in advance,
Nirmal
Re: EMF editor for customized XML output [message #518829 is a reply to message #518807] Fri, 05 March 2010 08:53 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Nirmal,

The things you describe could be handled just with extended meta data
annotations, as I mentioned already, i.e., they can be used to specify
the name used in the XML for any given feature and whether that feature
should be an element or an attribute.


Nirmal Sasidharan wrote:
> Hello Ed,
>
> Thanks a lot for your reply.
>
> I am thinking of using ecore2xml here, as the rules for my XML
> generation from the meta-model are straightforward. For example, all
> CamelCased model elements names are written out in uppercase with a
> hyphen in between (PurchaseOrder as PURCHASE-ORDER). There are some
> more rules on attribute and reference handling, but they are generic
> too. I don't want to declaratively create mappings for my model
> elements, but rather inspect the meta-model at runtime and create
> these rules. Do you think this could be managed by using ecore2xml
> programmatically rather than declaratively?
> Would this be the right approach or are there some other hooks in
> XMLResourceImpl with which the output could be customized
> programmatically?
>
> Thanks in advance,
> Nirmal


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:[Teneo] EObjectValidator rev 1.15
Next Topic:Inegrating ECore Models
Goto Forum:
  


Current Time: Thu Apr 25 02:33:36 GMT 2024

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

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

Back to the top