Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [EMF] parse enum values surrounded by whitespace
[EMF] parse enum values surrounded by whitespace [message #1842705] Tue, 29 June 2021 12:13 Go to next message
Wilbert Alberts is currently offline Wilbert AlbertsFriend
Messages: 209
Registered: June 2010
Senior Member
Hi,

I created a genmodel (and ecore model) from an existing xml schema definition. The model contains a couple of enumerations. Then I generate an implementation and try to read some of the models I have (using the xmi serialization). These models are manually created. When parsing a list of enumeration values, some users have written:

   <SupportedFormats>
      <elt>SUPPORTED_REPORT_FORMAT_TYPE_XML</elt>
   </SupportedFormats>


Others have written:
   <SupportedFormats>
      <elt>
         SUPPORTED_REPORT_FORMAT_TYPE_XML
      </elt>
   </SupportedFormats>


The implementation I generated, does not succesfully parse the second example as it tries to lookup an enumeration value that includes the newlines after <elt> and before </elt>.

Is there a way to configure the xmi parser such that it 'trims' whitespace of enumeration before trying to match them agains the set of allowed values?

Regards,
Wilbert
Re: [EMF] parse enum values surrounded by whitespace [message #1842709 is a reply to message #1842705] Tue, 29 June 2021 12:44 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33143
Registered: July 2009
Senior Member
You'll need to specialize the implementation of the generated XyzFactoryImpl.createAbcFromString method to trim whitespace before looking up the enumerator.

Ed Merks
Professional Support: https://www.macromodeling.com/
Re: [EMF] parse enum values surrounded by whitespace [message #1842711 is a reply to message #1842709] Tue, 29 June 2021 12:50 Go to previous message
Wilbert Alberts is currently offline Wilbert AlbertsFriend
Messages: 209
Registered: June 2010
Senior Member
Hi Ed,

You just beat me to it.

The genmodel properties for an enumeration containa 'Convert-to-string Body' and a 'Create-from-string Body'. Copying the generated code of another enumeration and inserting the trim() operation in the Create-from-string Body did the trick indeed.

Thanks!

Regards,
Wilbert.
Previous Topic:Parsing a nested JSON containment references list
Next Topic:EMF model in runtime
Goto Forum:
  


Current Time: Thu May 02 04:33:35 GMT 2024

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

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

Back to the top