Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » Default value serialization in XMI
Default value serialization in XMI [message #1852757] Fri, 03 June 2022 06:11 Go to next message
Yves BERNARD is currently offline Yves BERNARDFriend
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 Go to previous messageGo to next message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 581
Registered: September 2012
Location: Belgium
Senior Member

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 Go to previous message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 581
Registered: September 2012
Location: Belgium
Senior Member

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

Previous Topic:Create target UML Association with conditions
Next Topic:ATL Helper Context Assignment
Goto Forum:
  


Current Time: Sat Nov 11 08:17:06 GMT 2023

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

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

Back to the top