Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Auto generated type names by EMF Generator for XSD Elements(What algorithm determines the type name generated)
Auto generated type names by EMF Generator for XSD Elements [message #1716557] Fri, 04 December 2015 19:23 Go to next message
Robert Scott is currently offline Robert ScottFriend
Messages: 15
Registered: June 2015
Junior Member
Is there an algorithm for the type names generated? I have an XSD with elements structures defined without using named types. EMF generator assigns type names for these as Element Name + "Type" (with the 1st letter caps). My XSD is VERY large and element names are frequently duplicated. EMF generator assigns type name + counter to subsequent occurrences of the same element name. Now I am writing a Python tool to generating a Sirius VSM from the same XSD so I need to generate the same type names in the VSM as used in the generated Ecore Model. I'm can't see the pattern for the counter value that is appended to the type name in order to generate the matching type name in the VSM. If I process the XSD depth first or process all root level items first there are still cases that don't match.
Re: Auto generated type names by EMF Generator for XSD Elements [message #1716573 is a reply to message #1716557] Sat, 05 December 2015 05:43 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Robert,

Comments below.


On 04/12/2015 8:23 PM, Robert Scott wrote:
> Is there an algorithm for the type names generated?
No, it's completely random. :-P
> I have an XSD with elements structures defined without using named
> types. EMF generator assigns type names for these as Element Name +
> "Type" (with the 1st letter caps). My XSD is VERY large and element
> names are frequently duplicated.
So you have many elements with the same name but different anonymous types.
> EMF generator assigns type name + counter to subsequent occurrences of
> the same element name.
Yes.
> Now I am writing a Python tool to generating a Sirius VSM from the
> same XSD so I need to generate the same type names in the VSM as used
> in the generated Ecore Model. I'm can't see the pattern for the
> counter value that is appended to the type name in order to generate
> the matching type name in the VSM. If I process the XSD depth first
> or process all root level items first there are still cases that don't
> match.
The visiting pattern in
org.eclipse.xsd.ecore.XSDEcoreBuilder.generate(XSDSchema) visits the
logical structure of the schema, so that's going to be hard to reproduce
without reusing the XSD model. It involves visiting all the elements,
attributes, and then types, and each of those is alphabetically sorted.
Visiting involves walking the deep logical structure, creating the
corresponding Ecore model during the walk. Name conflicts are resolved
after the full traversal.

Your best bet would be to make use of the XSDEcoreBuilder to produce a
map you can use as part of the input to your Python generator (or use it
to annotate the schema).


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Auto generated type names by EMF Generator for XSD Elements [message #1716598 is a reply to message #1716573] Sun, 06 December 2015 06:11 Go to previous messageGo to next message
Robert Scott is currently offline Robert ScottFriend
Messages: 15
Registered: June 2015
Junior Member
Thanks for your reply I'm looking into some alternatives like auto-rewrite my XSD with named types or interface with Ecore for the names or like you said generate a map. I can duplicate the visiting order too but that's a dependency I may want to avoid. I'll update when its done. Thanks again.
Re: Auto generated type names by EMF Generator for XSD Elements [message #1717783 is a reply to message #1716598] Wed, 16 December 2015 16:45 Go to previous message
Robert Scott is currently offline Robert ScottFriend
Messages: 15
Registered: June 2015
Junior Member
Solution I used: Export the emf genmodel as xml sxhema: Select the top element under the .genmodel context menu-> export model. Then select XML schema as the model exporter. This generates an XSD that uses named types and is annotated with ecore names. I Used this as the input to my python script to generate a VSM that uses the type names matching the ecore model. Works great.
Previous Topic:Evolving from POJO to EMF
Next Topic:[CDO] server serving more than one repository
Goto Forum:
  


Current Time: Thu Apr 25 15:02:17 GMT 2024

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

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

Back to the top