Default value serialization in XMI [message #1852757] |
Fri, 03 June 2022 06:11 |
Yves BERNARD Messages: 146 Registered: July 2014 |
Senior Member |
|
|
Hello,
Is there any way to activate the XMI serialization of default values in ATL output files without having to go for a full java code + ATL API?
I didn't find any option for this in the ATL configuration.
For instance, would it be possible to use a call to a native java method for this purpose?
Thanks
Yves
|
|
|
Re: Default value serialization in XMI [message #1852804 is a reply to message #1852757] |
Sat, 04 June 2022 14:15 |
|
There's indeed no way to pass EMF serialization options to an ATL launch configuration: that can only be done in Java. If you use your own metamodel/EMF plugin, you can simply change the default options for serialization in your Resource.Factory implementation.
For an existing, third-party metamodel/EMF plugin, you can write a "wrapper" Eclipse plugin that registers a customised Resource.Factory with a custom file extension. Whenever you use the custom file extension in an ATL launch config, it will use the custom serialization options you set in the wrapper plugin that you wrote.
Cheers,
Dennis
|
|
|
Re: Default value serialization in XMI [message #1852805 is a reply to message #1852804] |
Sat, 04 June 2022 14:38 |
|
That said, you can probably also hack something from within ATL/EMFTVM. Here's the code from a custom XSD Eclipse plugin:
/**
* Creates an instance of the resource.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public Resource createResource(URI uri) {
XMLResource result = new MyCustomSchemaResourceImpl(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;
}
That suggests you can access the Resource object and put new options:
object.eResource().getDefaultSaveOptions().put('KEEP_DEFAULT_CONTENT', true);
Cheers,
Dennis
[Updated on: Sat, 04 June 2022 14:38] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.01640 seconds