Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » XSD2GenModel: set package name for java generated code
XSD2GenModel: set package name for java generated code [message #1857281] Fri, 27 January 2023 20:34 Go to next message
Missing name Mising name is currently offline Missing name Mising nameFriend
Messages: 7
Registered: May 2010
Junior Member
Hi all,
I use org.eclipse.emf.codegen.ecore.XSD2GenModel application
(in headless mode) to create the genmodel and ecore files.
I would like to set the package name that will be used by the generated java code
How can I do? I cannot find any option in this application
(nor in the org.eclipse.emf.codegen.ecore.Generator application
I use afterwards to generate the javacode) to do that.
Thanks for your answers.
Thomas

[Updated on: Fri, 27 January 2023 20:35]

Report message to a moderator

Re: XSD2GenModel: set package name for java generated code [message #1857285 is a reply to message #1857281] Sat, 28 January 2023 05:47 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33143
Registered: July 2009
Senior Member
Perhaps better to create the GenModel with the settings you want and reload it with the application...

In general, you can control settings of the GenModel via GenModel annotations on the Ecore model and you can control those annotations via annotations in the XSD, e.g., this on the xsd:schema element:
  xmlns:genmodel="http://www.eclipse.org/emf/2002/GenModel" 
  genmodel:basePackage="org.example"


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: XSD2GenModel: set package name for java generated code [message #1857289 is a reply to message #1857285] Sat, 28 January 2023 08:21 Go to previous messageGo to next message
Missing name Mising name is currently offline Missing name Mising nameFriend
Messages: 7
Registered: May 2010
Junior Member
That was exactly the kind of tip I was looking for, thanks!
Do you know where can I find the list of genmodel annotations
I can use in the xsd?
Re: XSD2GenModel: set package name for java generated code [message #1857290 is a reply to message #1857289] Sat, 28 January 2023 08:40 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33143
Registered: July 2009
Senior Member
There is no list. But if you open any *.ecore, and on any object use New -> EAnnotation -> "GenModel", in the properties view you see all the possible properties you can set which is pretty much the names of the corresponding GenXyz's features. Changing the value will record it as an annotation and that shows the name you can use

Ed Merks
Professional Support: https://www.macromodeling.com/
Re: XSD2GenModel: set package name for java generated code [message #1857292 is a reply to message #1857290] Sat, 28 January 2023 17:44 Go to previous messageGo to next message
Missing name Mising name is currently offline Missing name Mising nameFriend
Messages: 7
Registered: May 2010
Junior Member
Thank you very much for your help.
Re: XSD2GenModel: set package name for java generated code [message #1857313 is a reply to message #1857292] Mon, 30 January 2023 09:00 Go to previous messageGo to next message
Missing name Mising name is currently offline Missing name Mising nameFriend
Messages: 7
Registered: May 2010
Junior Member
I tested the genmodel:basePackage annotation in the xsd file but it does not seem to work.
It creates a eAnnotation tag in the ecore file, but it does not add the basePackage attribute in the genmodel file :-(
Re: XSD2GenModel: set package name for java generated code [message #1857317 is a reply to message #1857313] Mon, 30 January 2023 10:26 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33143
Registered: July 2009
Senior Member
Are you creating a new *.genmodel during this process or updating an existing one? I do expect org.eclipse.emf.codegen.ecore.genmodel.impl.GenPackageImpl.initialize(EPackage) to set it if it's not already set:
  public void initialize(EPackage ePackage)
  {
    if (getPrefixGen() == null && ePackage.getName() != null)
    {
      setPrefix(capName(ePackage.getName()));
    }

    if (getBasePackageGen() == null && EcoreUtil.getAnnotation(ePackage, GenModelPackage.eNS_URI, "basePackage") != null)
    {
      setBasePackage(EcoreUtil.getAnnotation(ePackage, GenModelPackage.eNS_URI, "basePackage"));
    




Ed Merks
Professional Support: https://www.macromodeling.com/
Re: XSD2GenModel: set package name for java generated code [message #1857324 is a reply to message #1857317] Mon, 30 January 2023 13:39 Go to previous message
Missing name Mising name is currently offline Missing name Mising nameFriend
Messages: 7
Registered: May 2010
Junior Member
I don't know what I did previously but now it's working. Maybe a typo...
Anyway, thank you very much for your help.
Previous Topic:Documentation generator for Ecore models
Next Topic:[CDO] DevOps installation
Goto Forum:
  


Current Time: Thu May 02 06:52:24 GMT 2024

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

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

Back to the top