Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [ATL] Getting ATL output file to correspond to correct Meta-Model(When the file extension isn't the expected one)
[ATL] Getting ATL output file to correspond to correct Meta-Model [message #715073] Fri, 12 August 2011 05:53 Go to next message
Anders Olsson is currently offline Anders Olsson
Messages: 21
Registered: July 2009
Junior Member
Hi,

I'm running an ATL transformation programmatically using the CoreService/Injector method (just like this guy: http://www.eclipse.org/forums/index.php/mv/tree/207021/662785/).

Things are working fine, for most parts. I have one problem I can't iron out: I can't get proper serialization when I specify an output file with the wrong file extension. That is, in the end step
extractor.extract(targetModel, outFile.toURI().toString());
, I get different output depending on if the extension is e.g. "xml" or if it's "mixed" (the default for my meta-model).

I know file extensions are holy to EMF, and that this behavior is quite expected. When the file extension is "xml" it will choose the default Factory for that type, which is XMI. What I'm interested in is how I register my Meta-model's Factory as the one to use for this file extension during this operation.

I've previously been guided on how this is done on a global or ResourceSet level (http://www.eclipse.org/forums/index.php/t/207614/), but fail to see how they would be used here. I have no control over which ResourceSet is used during the extraction, and setting this globally didn't do what I'd hoped. I used:
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("XML", new MixedResourceFactoryImpl());

but that caused problem when doing other operations, and made no difference for the output.

Is there a proper way to achieve this in ATL?

Thanks & Best Regards,

Anders

[Updated on: Fri, 12 August 2011 05:54]

Report message to a moderator

Re: [ATL] Getting ATL output file to correspond to correct Meta-Model [message #717698 is a reply to message #715073] Mon, 22 August 2011 02:23 Go to previous message
Anders Olsson is currently offline Anders Olsson
Messages: 21
Registered: July 2009
Junior Member
I found the answer to my question.

Turns out, you can cast the IExtractor to an EMFExtractor (the only implementation of IExtractor thus far). That Class has one more extract method than the Interface has exposed: extract(EMFModel sourceModel, OutputStream target, String fileExtension, Map<String, Object> options). Setting the fileExtension to the correct type achieves exactly what I was looking for.

Previous Topic:[ATL] random function available?
Next Topic:eoperation in atl
Goto Forum:
  


Current Time: Thu Apr 17 03:47:35 EDT 2014

Powered by FUDForum. Page generated in 0.01634 seconds