3. Variables
Introduction
Variable is a container that holds a value and can be called in the iXPath Scenario. The importance of
variables is to make flexibility in using some values without referring to their origins.
There are 2 types of variables:
- System variables
- Local variables
To call a variable, we should put it inside ${}. Eg: for a variable named ‘iXVar’, it can be called as ${iXVar}.
System variables
System variables define some default values in the system, and they can be called by users several times.
Here is the list of system variables :
- At the declaration of the scenario:
- iXSession: it returns the ID of the current session.
- iXSessionPath: gets the Path of the session folder.
- env: name of the environment.
- inputFile: this variable collect all input files in one list.
- For a mail listener :
- iXFrom: refers to the sender of the mail.
- iXSubject: refers to the mail subject.
- For an AS2 listener :
- iXFrom: return the value of the AS2 sender.
- All connectors declare a system variable of type BpmnFile, the connector variable uses a bunch of functions to handle the list of BpmnFiles that will be detailed in the table below :
Function Description Use Get Get a file with index number "x" from the BpmnFile list, the indexes begin from 0 as the first element, and so on. if we have an XmlToXml connector named "XmlToXml1" we can get the second BpmnFile as :
${XmlToXml1.get(1)}
NB: we will make examples on the same connector "XmlToXml1".
getTrkValues() Return the Tracking values from a BpmnFile. Eg : ${XmlToXml1.get(0).getTrkValues()} returns the tracking values of the first BpmnFile. path() Return the absolute path of the BpmnFile. Eg : ${XmlToXml.get(3).path()} returns the path of the fourth BpmnFile fileName() Return the name of the BpmnFile. Eg : ${XmlToXml1.get(2).fileName()} retrieves the name of the third BpmnFile. extension() Returns the extension of the BpmnFile. Eg : if we want to get the extension of the first BpmnFile, we will proceed as below :
${XmlToXml1.get(0).extension()}
fullName() Returns the file name + its extension Eg : ${XmlToXml1.get(0).fullName()} returns the full name of the BpmnFile. size() Returns the size of the BpmnFile in megabit. Eg : ${XmlToXml1.get(0).size()} returns the size of the first BpmnFile.
type() Returns the type of the BpmnFile Eg : To get the type of the second BpmnFile ,
${XmlToXml1.get(1).type()}
Local variables
Local variable is a type of variable that can be newly created and used for a certain need.
So as to create a local variable "newVar" with a value equals to "var number 1", we should write this piece of XSL code :
The call of this new variable in the scenario is similar to previous system variables: ${newVar}.
To get 'newVar' inside an XSL file :
Examples
We set a simple example of a scenario to illustrate how to use variables.
We want to receive a file by a FileListener and send it by mail that contains a message body.
here is the scenario:
The configuration of the "SendMail" is :
As shown in the mail body, we called 3 variables which are :
- Env : the current environment
- iXSession : ID session
- path : path of the BpmnFile in FileListener1.