Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » XSD to Ecore: Group renamed to Group1(...even in created XML)
XSD to Ecore: Group renamed to Group1 [message #1823901] Fri, 03 April 2020 15:11 Go to next message
Gunnar Arndt is currently offline Gunnar ArndtFriend
Messages: 82
Registered: June 2012
Member
Dear friends,

I have created an Ecore model from the OTX (Open Test eXchange) XML schema definition. It defines types called Flow and Group; a Flow can contain Group items:
<xsd:complexType name="Group" />
<xsd:complexType name="Flow">
    <xsd:sequence>
      <xsd:choice minOccurs="0" maxOccurs="unbounded">
        <xsd:element name="group" type="otx:Group" minOccurs="1" maxOccurs="1"/>
...

As 'Group' seems to be a reserved feature name in Ecore, the Flow class created by importing otx.xsd receives a feature Group1 for the business logic part instead.
That does not matter for me in the first place, but leads to the issue that the XML tag used when storing OTX models created with the Ecore isgroup1, where it should be group:
<flow>
  <group1 />
</flow>

What can I do about this? How to change the XML tag, or better yet, the feature name?
Thank you.
Re: XSD to Ecore: Group renamed to Group1 [message #1823932 is a reply to message #1823901] Sat, 04 April 2020 05:20 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
I expect you are not using the generated XyzResourceFactoryImpl to save your resource. The class contains this method
  public Resource createResource(URI uri)
  {
    XMLResource result = new XyzResourceImpl(uri);
    result.getDefaultSaveOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);
    result.getDefaultLoadOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);

    result.getDefaultSaveOptions().put(XMLResource.OPTION_SCHEMA_LOCATION, Boolean.TRUE);

    result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE, Boolean.TRUE);
    result.getDefaultSaveOptions().put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE, Boolean.TRUE);

    result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_LEXICAL_HANDLER, Boolean.TRUE);
    return result;
  }
Those options are important for the extended metadata annotations on the Ecore model to be used properly during loading and saving.

So be sure which factory is being used to create your resource. This will generally depend on the file extension you use because that's registered in the plugin.xml
   <extension point="org.eclipse.emf.ecore.extension_parser">
      <!-- @generated xyz-->
      <parser
            type="xyz"
            class="org.eclipse.example.xyz.util.XyzResourceFactoryImpl"/>
   </extension>
Via the GenPackage's properties (nested under the GenModel at the root of the *.genmodel resource), the File Extensions property controls what's in the plugin.xml It's also possible to specify a Content Type Identifier so that you can reuse extension xml, but then you have to be sure to create the resource using org.eclipse.emf.ecore.resource.ResourceSet.createResource(URI, String), specifying your Content Type Identifier a constant for which will be in your generated XyzPackage.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: XSD to Ecore: Group renamed to Group1 [message #1823992 is a reply to message #1823932] Mon, 06 April 2020 09:31 Go to previous messageGo to next message
Gunnar Arndt is currently offline Gunnar ArndtFriend
Messages: 82
Registered: June 2012
Member
Ed, thank you for the detailed explanation. Indeed I found that the issue only occurs when the XML output is created by an ATL transformation called from an Eclipse launch config. That operation seems to use its own ResourceFactories. When the ATL transformation is executed from within a Java program, the correct XML tag is written.
Re: XSD to Ecore: Group renamed to Group1 [message #1824009 is a reply to message #1823992] Mon, 06 April 2020 13:17 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

Since it works as a Java invocation, your Java code is presumably initializing in a way that Eclipse doesn't which is probably due to a deficiency on your part.

Are you using a distinctive *.xyx extension?

Have you registered the XyzResourceFactory for use by your *.xyz extension?

Have you really done so? i.e. are they on the classpath? ... numerous other build snafus.

If using *.xml as your extension, you will need to work much harder to register your content type and ensure that it is not occluded by a .* registation.

Regards

Ed Willink
Previous Topic:Override IItemLabelProvider.getText() for all derived classes
Next Topic:[EMF] long loading time
Goto Forum:
  


Current Time: Thu Mar 28 11:19:01 GMT 2024

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

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

Back to the top