Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » Querys in templates without empty line?(Include querys in templates without printing an empty line in the output?)
Querys in templates without empty line? [message #1699252] Tue, 23 June 2015 04:34 Go to next message
Martin Gruber is currently offline Martin GruberFriend
Messages: 6
Registered: May 2015
Junior Member
Hello together,
I am using Java services and hence querys to do some additional calculations or checks.

In some cases, the java services (and so the querys) shall return *nothing* or *null*. For example if no matching objects where found.

I call this querys with a simple
[queryName/]

In this case, I will get newlines in the target file after each query even if the return value of the service is null.

Is there a possiblity to avoid this newlines in case of "no" return of the query?

Kind Regards and thank you in advice,
Martin
Re: Querys in templates without empty line? [message #1699255 is a reply to message #1699252] Tue, 23 June 2015 05:39 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 5586
Registered: July 2009
Senior Member
Hi

Generally the new line from

[queryName/] <NL>

comes from the <NL> following the empty query. If you don't want it,
don't put a <NL> there, i.e you must have long unreadable lines.

Or embed the query within an if that gives you some control, although I
never could fathom quite which <NL>s in an if are ignored. So you are in
the realm of empirical programming.

Getting your output to be immaculately pretty printed can require quite
a lot of experiment.

Alternatively follow Acceleo's advice and follow the transformation with
a pretty printer.

Regards

Ed Willink



On 23/06/2015 05:34, Martin Gruber wrote:
> Hello together,
> I am using Java services and hence querys to do some additional
> calculations or checks.
>
> In some cases, the java services (and so the querys) shall return
> *nothing* or *null*. For example if no matching objects where found.
>
> I call this querys with a simple
> [queryName/]
>
> In this case, I will get newlines in the target file after each query
> even if the return value of the service is null.
>
> Is there a possiblity to avoid this newlines in case of "no" return of
> the query?
>
> Kind Regards and thank you in advice,
> Martin
Previous Topic:Method to save and edit values in ACCELEO templates
Next Topic:MoDisco Model to Java Source Code
Goto Forum:
  


Current Time: Wed Jan 24 06:05:47 GMT 2018

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

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