Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Gendoc » Using fragments in if statements
Using fragments in if statements [message #1720863] Thu, 21 January 2016 14:08 Go to next message
Axel Thor Asthorsson is currently offline Axel Thor AsthorssonFriend
Messages: 18
Registered: May 2015
Junior Member
Hello.

I am using the following fragment to display values in SpecObjects and Specification in reqif10 models:

<fragment name='getValue'>
<arg name='specElement' type='reqif10::SpecElementWithAttributes'/>
<arg name='attribute' type='String'/>
[for (value:AttributeValue|specElement.values)]
[if(value.eGet('definition').longName=attribute)]
[value.eGet('theValue')/]
[/if]
[/for]
</fragment>


However when I try to call this fragment in a if statement such as :
[if(purpose.getValue('visible in doc') = true
or
[if(purpose.getValue('visible in doc') = 'true'


it does not work. Is it possible to let fragments return something so they can be used in conditional statements? This variable 'visible in doc' is defined as boolean in the reqif10 model. Just to be clear, the fragment works fine when showing the content in the document.

best regards
Axel Thor
Re: Using fragments in if statements [message #1721146 is a reply to message #1720863] Mon, 25 January 2016 08:16 Go to previous messageGo to next message
Tristan Faure is currently offline Tristan FaureFriend
Messages: 426
Registered: July 2009
Senior Member
Hello
fragments are sub templates so the content is inserted in the doc,
What you want to achieve is a query I think the best in your case is to create a plugin library which will contain your queries.

I will post here asap a process to do this

EDIT : instructions to create queries are listed in this post : https://www.eclipse.org/forums/index.php/t/1065528/




[Updated on: Tue, 26 January 2016 11:40]

Report message to a moderator

Re: Using fragments in if statements [message #1721908 is a reply to message #1721146] Mon, 01 February 2016 16:00 Go to previous messageGo to next message
Axel Thor Asthorsson is currently offline Axel Thor AsthorssonFriend
Messages: 18
Registered: May 2015
Junior Member
Thanks for this Smile I was also able to set global variables using gPut in the fragment and then gGet in the <gendoc> section to check the value. Using acceleo modules is obviously a better way to accomplish this.

Having said that, can you explain to me this scenario:

[specObject.getValue('text')/]<drop/>
<image keepW='true' filePath='[gGet('figure_dir')/][gGet('returnValue')/]'><drop/>
 an image
</image><drop/>
[/if]<drop/>
[if (specObject.type.longName = 'Capella Diagram')]<drop/>
[specObject.getValue('text')/]<drop/>
<image keepW='true' filePath='[gGet('capella_diagram_dir')/]/[gGet('returnVAlue')/].jpg'><drop/>
 
</image><drop/>


When I call getValue fragment which runs gPut('returnValue....) twice in the same <gendoc> section, the only way to access the different return values is to run gGet('returnValue') the first time, and then gGet('returnVAlue') the second time etc. I.e. I always have to change a little bit how the 'returnValue' string is written every time I call getValue.

Re: Using fragments in if statements [message #1721912 is a reply to message #1721908] Mon, 01 February 2016 16:18 Go to previous message
Tristan Faure is currently offline Tristan FaureFriend
Messages: 426
Registered: July 2009
Senior Member
Hello
Acceleo has a cache which returns always the same value for the same input

You can disable the Acceleo cache (take care of potential performance problems) using :
Window > Preferences > Toggle the cache of evaluation queries




Previous Topic:Diagrams are not displayed in generated document with sirius bundle
Next Topic:images in fragments
Goto Forum:
  


Current Time: Sun Nov 18 10:45:13 GMT 2018

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

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

Back to the top