Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » [ATL] How to change ecoding(How to change the encoding of a transformation xmi file from "ISO-8859-1" to "ASCII")
[ATL] How to change ecoding [message #923322] Tue, 25 September 2012 20:34 Go to next message
lili Mising name is currently offline lili Mising nameFriend
Messages: 8
Registered: July 2011
Junior Member
Hello,

I'm facing a problem and a googled to find a solution, but couldn't solve. I have an ATL transformation that generate a file, after that i'm trying to use this file on my application, but i was facing a org.eclipse.emf.ecore.xmi.FeatureNotFoundException. So i made some tests and i think my problem is related to the encoding of ATL generated file.

Im trying to import the ATL generated tha is something like this:
[code]
<?xml version="1.0" encoding="ISO-8859-1"?>
<a:A xmi:version="2.0" xmlns:xmi="http: //www .omg.org/XMI" xmlns:a="http: // a/1.0">
<event msg="Teste"/>
</a:A>

With this i get org.eclipse.emf.ecore.xmi.FeatureNotFoundException

But if i export a file from my app (not ATL transformed) i have thi:

<?xml version="1.0" encoding="ASCII"?>
<a:A xmi:version="2.0" xmlns:xmi="http : //www .omg.org/XMI" xmlns:a="http : // a/1.0">
  <event msg="Teste"/>
</a:A>


For this last one i used the simple resource saving...
	APackage.eINSTANCE.eClass();
	// Retrieve the default factory singleton
	AFactory factory = AFactory.eINSTANCE;      
	// Create the content of the model via this program
	A ap = factory.createA();
        Event ev = factory.createEvent();
        ev.setMsg("Teste");
	ap.setEvent(ev);                
	// Register the XMI resource factory for the .a extension
	Resource.Factory.Registry reg = Resource.Factory.Registry.INSTANCE;                
	Map<String, Object> m = reg.getExtensionToFactoryMap();
        m.put("a", new XMIResourceFactoryImpl());

	// Obtain a new resource set
	ResourceSet resSet = new ResourceSetImpl();
	// Create a resource
	Resource resource = resSet.createResource(URI
		.createURI("teste.a"));
	resource.getContents().add(ap);
	// Now save the content.
	try {
            resource.save(Collections.EMPTY_MAP);
	} catch (IOException e) {
	  e.printStackTrace();
	}





And with the last one the same code to import works fine...So i thik the problem is the codification of the file.

How to solve encoding incompatibility problems? Is that a way of changing the default encoding on ATL or on the resource saving?

Thanks!
Re: [ATL] How to change ecoding [message #937070 is a reply to message #923322] Mon, 08 October 2012 16:28 Go to previous messageGo to next message
Ronan B is currently offline Ronan BFriend
Messages: 273
Registered: July 2009
Senior Member
Hi,
You cannot control the encoding in ATL. ATL will leave the serialization to the Resource associated with your output MetaModel. For example you can control many aspects of the output in the ResourceFactoryImpl which is generated off your ecore MetaModel. take a look at the org.eclipse.emf.ecore.resource.impl and org.eclipse.emf.ecore.xmi APIs for some inspiration.
Regards,
Ronan
Re: [ATL] How to change ecoding [message #937084 is a reply to message #923322] Mon, 08 October 2012 16:39 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

I would be surprised if the encoding is a problem unless you have some
feature names or URIs that use non-ASCII 96 characters.

Without details on the FNFE it's difficult to comment further.

Regards

Ed Willink

On 25/09/2012 21:34, lili Mising name wrote:
> Hello,
> I'm facing a problem and a googled to find a solution, but couldn't
> solve. I have an ATL transformation that generate a file, after that
> i'm trying to use this file on my application, but i was facing a
> org.eclipse.emf.ecore.xmi.FeatureNotFoundException. So i made some
> tests and i think my problem is related to the encoding of ATL
> generated file.
> Im trying to import the ATL generated tha is something like this:
> [code]
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <a:A xmi:version="2.0" xmlns:xmi="http: //www .omg.org/XMI"
> xmlns:a="http: // a/1.0">
> <event msg="Teste"/>
> </a:A>
>
> With this i get org.eclipse.emf.ecore.xmi.FeatureNotFoundException
>
> But if i export a file from my app (not ATL transformed) i have thi:
>
>
> <?xml version="1.0" encoding="ASCII"?>
> <a:A xmi:version="2.0" xmlns:xmi="http : //www .omg.org/XMI"
> xmlns:a="http : // a/1.0">
> <event msg="Teste"/>
> </a:A>
>
>
> For this last one i used the simple resource saving...
>
> APackage.eINSTANCE.eClass();
> // Retrieve the default factory singleton
> AFactory factory = AFactory.eINSTANCE; // Create the
> content of the model via this program
> A ap = factory.createA();
> Event ev = factory.createEvent();
> ev.setMsg("Teste");
> ap.setEvent(ev); // Register the XMI resource
> factory for the .a extension
> Resource.Factory.Registry reg =
> Resource.Factory.Registry.INSTANCE; Map<String,
> Object> m = reg.getExtensionToFactoryMap();
> m.put("a", new XMIResourceFactoryImpl());
>
> // Obtain a new resource set
> ResourceSet resSet = new ResourceSetImpl();
> // Create a resource
> Resource resource = resSet.createResource(URI
> .createURI("teste.a"));
> resource.getContents().add(ap);
> // Now save the content.
> try {
> resource.save(Collections.EMPTY_MAP);
> } catch (IOException e) {
> e.printStackTrace();
> }
>
>
>
>
>
> And with the last one the same code to import works fine...So i thik
> the problem is the codification of the file.
>
> How to solve encoding incompatibility problems? Is that a way of
> changing the default encoding on ATL or on the resource saving?
>
> Thanks!
>
Previous Topic:error
Next Topic:ATL ignores elements inside a UML PackageImport
Goto Forum:
  


Current Time: Fri Mar 29 01:09:18 GMT 2024

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

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

Back to the top