Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [Acceleo 3] - Expression in <init> clause of template(Syntax question)
[Acceleo 3] - Expression in <init> clause of template [message #650849] Wed, 26 January 2011 20:06 Go to next message
Luc De Graef is currently offline Luc De GraefFriend
Messages: 7
Registered: January 2011
Junior Member
Hello,

I want to use the <init> clause of a template to initialize some variables based on the additional parameters.

[template public ddl(item : Item, isAuditTable : Boolean, suffix : String)
{
   tableName : String = item.name + 'xxx';
  fullTableName : String = item.name + (isAuditTable ? '_AUDIT' : '_NORMAL');
}	
]


I get a compilation error 'unexpected tokens' on the use of (isAuditTable ? '...' : '...)

Is there a way to use a 'conditional expression' in the init clause?

Regards
Luc
Re: [Acceleo 3] - Expression in <init> clause of template [message #650922 is a reply to message #650849] Thu, 27 January 2011 07:55 Go to previous messageGo to next message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1902
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------010403080802030400070306
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

Hi Luc,

There is no ternary operator in OCL. You have to use a regular "if else
endif" :

fullTableName : String = item.name + (if (isAuditTable) then '_AUDIT'
else '_NORMAL' endif);

Laurent Goubet
Obeo

On 26/01/2011 21:06, Luc De Graef wrote:
> Hello,
>
> I want to use the <init> clause of a template to initialize some
> variables based on the additional parameters.
>
>
> [template public ddl(item : Item, isAuditTable : Boolean, suffix : String)
> {
> tableName : String = item.name + 'xxx';
> fullTableName : String = item.name + (isAuditTable ? '_AUDIT' : '_NORMAL');
> }
> ]
>
>
> I get a compilation error 'unexpected tokens' on the use of
> (isAuditTable ? '...' : '...)
>
> Is there a way to use a 'conditional expression' in the init clause?
>
> Regards
> Luc


--------------010403080802030400070306
Content-Type: text/x-vcard; charset=utf-8;
name="laurent_goubet.vcf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="laurent_goubet.vcf"

YmVnaW46dmNhcmQNCmZuOkxhdXJlbnQgR291YmV0DQpuOkdvdWJldDtMYXVy ZW50DQpvcmc6
PGEgaHJlZj0iaHR0cDovL3d3dy5vYmVvLmZyIj5PYmVvPC9hPg0KZW1haWw7 aW50ZXJuZXQ6
bGF1cmVudC5nb3ViZXRAb2Jlby5mcg0KdXJsOmh0dHA6Ly93d3cub2Jlby5m cg0KdmVyc2lv
bjoyLjENCmVuZDp2Y2FyZA0KDQo=
--------------010403080802030400070306--
Re: [Acceleo 3] - Expression in <init> clause of template [message #650925 is a reply to message #650922] Thu, 27 January 2011 08:19 Go to previous messageGo to next message
Luc De Graef is currently offline Luc De GraefFriend
Messages: 7
Registered: January 2011
Junior Member
Thanks,

I had looked into the MOF Model to Text Specification Guide, but I now realize I need to review the OCL specifications also...

Regards,
Luc
Re: [Acceleo 3] - Expression in <init> clause of template [message #650934 is a reply to message #650925] Thu, 27 January 2011 08:26 Go to previous message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1902
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------030502080006060104070101
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

Yup, Acceleo is an implementation of the MOF Model to Text standard ...
but this itself heavily depends on OCL. Most of the "expressions" you
will use in Acceleo are in fact OCL expressions (augmented with our own
standard library operations).

We provide in the documentation (Help > Help Contents > Acceleo Model to
Text) a reference guide of the standard OCL operations. Though this
guide still sports some typos, you can use it in order to find your way
around OCL.

Laurent Goubet
Obeo

On 27/01/2011 09:19, Luc De Graef wrote:
> Thanks,
>
> I had looked into the MOF Model to Text Specification Guide, but I now
> realize I need to review the OCL specifications also...
>
> Regards,
> Luc


--------------030502080006060104070101
Content-Type: text/x-vcard; charset=utf-8;
name="laurent_goubet.vcf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="laurent_goubet.vcf"

YmVnaW46dmNhcmQNCmZuOkxhdXJlbnQgR291YmV0DQpuOkdvdWJldDtMYXVy ZW50DQpvcmc6
PGEgaHJlZj0iaHR0cDovL3d3dy5vYmVvLmZyIj5PYmVvPC9hPg0KZW1haWw7 aW50ZXJuZXQ6
bGF1cmVudC5nb3ViZXRAb2Jlby5mcg0KdXJsOmh0dHA6Ly93d3cub2Jlby5m cg0KdmVyc2lv
bjoyLjENCmVuZDp2Y2FyZA0KDQo=
--------------030502080006060104070101--
Previous Topic:M2T reverse direction
Next Topic:[Xpand] Verifying Xpand output
Goto Forum:
  


Current Time: Wed Dec 11 16:57:32 GMT 2024

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

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

Back to the top