Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [ATL] How to return a null value from a helper
[ATL] How to return a null value from a helper [message #490430] Thu, 08 October 2009 15:49 Go to next message
Tassilo Horn is currently offline Tassilo HornFriend
Messages: 93
Registered: July 2009
Member
Hi all,

I'm doing my first ATL transformation. There's one helper, that should
return the spouse of a given family member if there is one (You see, I'm
extending that Families2Person example).

So here is the code:

--8<---------------cut here---------------start------------->8---
helper context Families!Member def: spouse : Families!Member =
if not self.familyMother.oclIsUndefined() then
self.familyMother.father
else
if not self.familyFather.oclIsUndefined() then
self.familyFather.mother
else
null
endif
endif;
--8<---------------cut here---------------end--------------->8---

So if my member is neither the father nor the mother of a family, then
he has no spouse and I want to return null. But ATL tells me that the
variable null is undefined. So what's the null literal in OCL?

Bye,
Tassilo
Re: [ATL] How to return a null value from a helper [message #490476 is a reply to message #490430] Thu, 08 October 2009 18:31 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: j.neveux.netfective.com

Hi Tassilo,

self.familyMother is null so you need to check it this way:

self.familyMother <> OclUndefined

Regards,

Jean

"Tassilo Horn" <thorn@fastmail.fm> a
Re: [ATL] How to return a null value from a helper [message #490478 is a reply to message #490476] Thu, 08 October 2009 19:00 Go to previous message
Tassilo Horn is currently offline Tassilo HornFriend
Messages: 93
Registered: July 2009
Member
"Jean Neveux" <j.neveux@netfective.com> writes:

Hi Jean,

> self.familyMother is null so you need to check it this way:
>
> self.familyMother <> OclUndefined

I see, and I need to use OclUndefined as return value, too. Then it
works like a charm.

Thanks a lot,
Tassilo
Previous Topic:[ATL]missing elements in the output file
Next Topic:[QVTo] How to specify source & target [meta]models?
Goto Forum:
  


Current Time: Thu Apr 25 08:11:14 GMT 2024

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

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

Back to the top