Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 08:56 Go to next message
Bruce Trask is currently offline Bruce TraskFriend
Messages: 58
Registered: July 2009
Member
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 09:36]

Report message to a moderator

Re: QVTO - Calling a mapping versus clone [message #1783659 is a reply to message #1783657] Thu, 15 March 2018 09:25 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
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 09:37 Go to previous message
Bruce Trask is currently offline Bruce TraskFriend
Messages: 58
Registered: July 2009
Member
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: Tue Apr 16 12:17:04 GMT 2024

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

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

Back to the top