Skip to main content



      Home
Home » Modeling » QVT-OML » QVTO - Calling a mapping versus clone(Calling a mapping versus clone)
QVTO - Calling a mapping versus clone [message #1783657] Thu, 15 March 2018 04:56 Go to next message
Eclipse UserFriend
Hello,

I am seeing some odd behavior with a clone call.

I have a transformation file that I am using and it has the following line in it:

-- try clone here, rather than invoke a mapping
version := self.version.clone()->oclAsType(newone::Version)->any(true);
-- version := self.version.map toVersion();

with toVersion() being

mapping old::Version::toVersion() : newone::Version {
major := self.major;
minor := self.minor;
service := self.service;
}

When I run it I get some odd results in the resulting xmi file.

I see:

- dual xmlns entries in the XMI element.
<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:requirements="http://www.company.com/2018/requirements" xmlns:requirements_1="http://www.eclipse.org/2008/requirements">

-and the version gets added to the XMI element and not the subelement.
<requirements_1:Version major="1"/>
<requirements_1:Version minor="5"/>

When I run it with the toVersion mapping it works fine.

Was wondering if I am using the clone correctly and if in fact the clone call above should be the same as the call to the mapping.

Regards,
Bruce

[Updated on: Thu, 15 March 2018 05:36] by Moderator

Re: QVTO - Calling a mapping versus clone [message #1783659 is a reply to message #1783657] Thu, 15 March 2018 05:25 Go to previous messageGo to next message
Eclipse UserFriend
Hi

Without a repro it's hard to be sure but:

a) never use clone() or deepclone() - IMHO it's like using goto

b) self.version.clone()->oclAsType(newone::Version)->any(true) is really smelly. The only point I can see in the cast and select is to ensure that you get weird results.

self.version.clone() should work, but perhaps Eclipse QVTo has not caught up with a return type clarification in OMG QVT 1.3

self.version.clone().oclAsType(newone::Version) might work provided newone::Version is the correct type. No repro cannot diagnose.

self.version.clone()->oclAsType(newone::Version)->any(true) is self.version.clone().oclAsSet()->oclAsType(newone::Version)->any(true)

which should cast the set rather than collect the elemental casts, so at some point you get an execution failure and the orphan object appears at your model root just as you observe.

Regards

Ed Willink

Re: QVTO - Calling a mapping versus clone [message #1783661 is a reply to message #1783659] Thu, 15 March 2018 05:37 Go to previous message
Eclipse UserFriend
Hi Ed,

Ok. Thanks for the pointers. I will dive in and see what I find.

Regards,
Bruce
Previous Topic:Basic syntax question in mapping
Next Topic:Running a QVT transformation headless or from JUnit
Goto Forum:
  


Current Time: Mon Jul 14 08:07:31 EDT 2025

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

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

Back to the top