[ATL] Using XSD->EMF metamodel in ATL [message #491624] |
Thu, 15 October 2009 05:43  |
Eclipse User |
|
|
|
Hi all!
Being a beginner in ATL, I'm having a little trouble. My goal is to convert a EMF-based model (Ecore) to another model defined by XSD. I have created a Ecore version of the XSD model using xsd2ecore importer, and checked it's working with the generated EMF editor.
My next step was to create a simple ATL rule to test if the ATL part works:
module EMF2XSD;
create OUT : XSDmodel from IN : EMFmodel;
rule Node {
from
em : EMFmodel!Node
to
xs : XSDmodel!DocumentRoot (
comment <- 'bbbbbbbb'
)
}
This should create a XML file with just one lelement, like this:
<?xml version="1.0" encoding="ISO-8859-1"?>
<comment>bbbbbbbb</comment>
Instead, I get something like this:
<?xml version="1.0" encoding="ISO-8859-1"?>
<XSDmodel:DocumentRoot xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:XSDmodel="file:/D:/xsdmodel.xsd">
<comment>bbbbbbbb</comment>
</XSDmodel:DocumentRoot>
The DocumentRoot element should not occur here, there should be just the <comment> element. DocumentRoot is created as a part of XSD->EMF conversion.
Is there some way to use the xsd2ecore or genmodel mappings created when importing XSD to EMF to overcome this?
Thanks,
Marin.
|
|
|
|
|
Re: [ATL] Using XSD->EMF metamodel in ATL [message #491712 is a reply to message #491676] |
Thu, 15 October 2009 10:30   |
Eclipse User |
|
|
|
This is a multi-part message in MIME format.
--------------050909080201040100030909
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Hello,
AT this time, ATL launch configuration cannot parametrize that. The
factory is automatically detected by the file extension. Then if your
xsd doesn't specify one, and you use default ".xml", you need to
programmatically set the option.
This consists on loading the models, initializing the output model using
that method:
org.eclipse.m2m.atl.core.emf.EMFModel.setEmfResourceFactory( Factory)
using the correct EMF factory.
The finally launch the transformation.
Here you can find an example of programmatic launch:
http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.m2m/org .eclipse.m2m.atl/examples/org.eclipse.m2m.atl.examples.publi c2private.ui/src/org/eclipse/m2m/atl/examples/public2private /ui/PrivatizeAction.java?root=Modeling_Project&view=mark up
Also available when ATL is installe, just do :
New > Example...> ATL > Public to private
In the next ATL version (3.1, release next June), it will be possible to
specify content types (so, related factory) for model saving.
Best regards,
William
Marin Orlić a écrit :
>> I'd expect this if you used an XMIResourceImpl to serialize the
>> instance, rather than an XMLResourceImpl configured like the one in your
>> generated XyzResourceFactoryImpl.
>
> Now that you said it, it makes perfect sense :)
> I'm running the ATL from Eclipse, is there a way to set the serializer
> to the EMF-specific VN or the regular VM, I don't see such options..
> Is it only possible from ANT or Java? There are samples like Table2HTML
> that specify the XML extractor in build.xml.
>
> M.
--
Ne manquez pas notre prochaine formation ATL inter entreprises:
ATL - Paris - du 2 au 3 Décembre 2009
Pour plus de dates et pour le détail de cette formation:
http://www.obeo.fr/pages/formations/fr
Don't forget our next ATL training:
ATL - Paris - 2009 December from 2th to 3th
More dates and training program on:
http://www.obeo.fr/pages/formations/fr
--------------050909080201040100030909
Content-Type: text/x-vcard; charset=utf-8;
name="william_piers.vcf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="william_piers.vcf"
YmVnaW46dmNhcmQNCmZuOldpbGxpYW0gUGllcnMNCm46UGllcnM7V2lsbGlh bQ0Kb3JnOk9i
ZW8NCmFkcjoyIHJ1ZSBSb2JlcnQgU2NodW1hbm47O2xvdCAyNDtOQU5URVM7 OzQ0NDA4O0Zy
YW5jZQ0KZW1haWw7aW50ZXJuZXQ6d2lsbGlhbS5waWVyc0BvYmVvLmZyDQp0 aXRsZTpNREEg
Q29uc3VsdGFudA0KdGVsO3dvcms6KzMzICgwKTIgNTEgMTMgNTAgNTMNCnVy bDpodHRwOi8v
d3d3Lm9iZW8uZnINCnZlcnNpb246Mi4xDQplbmQ6dmNhcmQNCg0K
--------------050909080201040100030909--
|
|
|
|
Powered by
FUDForum. Page generated in 1.04533 seconds