[ATL] How to change ecoding [message #923322] |
Tue, 25 September 2012 16:34  |
Eclipse User |
|
|
|
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 #937084 is a reply to message #923322] |
Mon, 08 October 2012 12:39  |
Eclipse User |
|
|
|
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!
>
|
|
|
Powered by
FUDForum. Page generated in 0.07511 seconds