Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [ATL] Using XSD->EMF metamodel in ATL
[ATL] Using XSD->EMF metamodel in ATL [message #491624] Thu, 15 October 2009 09:43 Go to next message
Marin  rli? is currently offline Marin rli?Friend
Messages: 35
Registered: October 2009
Member
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 #491647 is a reply to message #491624] Thu, 15 October 2009 11:37 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
Marin,

Comments below.

Marin Orlić wrote:
> 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>
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.
>
>
> 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.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: [ATL] Using XSD->EMF metamodel in ATL [message #491676 is a reply to message #491647] Thu, 15 October 2009 13:11 Go to previous messageGo to next message
Marin  rli? is currently offline Marin rli?Friend
Messages: 35
Registered: October 2009
Member
> 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 Smile
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.
Re: [ATL] Using XSD->EMF metamodel in ATL [message #491712 is a reply to message #491676] Thu, 15 October 2009 14:30 Go to previous messageGo to next message
William Piers is currently offline William PiersFriend
Messages: 301
Registered: July 2009
Senior Member
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--
Re: [ATL] Using XSD->EMF metamodel in ATL [message #491726 is a reply to message #491712] Thu, 15 October 2009 15:05 Go to previous message
Marin  rli? is currently offline Marin rli?Friend
Messages: 35
Registered: October 2009
Member
I created the edit plugins for my metamodel and dropped them in the platform. When the output model file has the correct extension, the serialization works like a charm!

Thank you all Smile

M.
Previous Topic:[ATL] UML 2 Profiles
Next Topic:[ATL] ...emfvm.VMException caused by ClassCastException, but why?
Goto Forum:
  


Current Time: Fri Apr 26 22:08:17 GMT 2024

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

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

Back to the top