Macro components specify reusable boolean expressions, for use in trigger, composition, or interceptor components.
What’s in a macro?
A macro contains the following information:
|
Below is a description of macro schema syntax, and an example.
Macro schema syntax
The XML schema sis-macro-1.6.xsd defines macros, using the following schema namespaces:
<macro xmlns="http://www.opencloud.com/SIS/Macro"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.opencloud.com/SIS/Macro sis-macro-1.6.xsd">
Sample macro
The following sample macro normalises the address contained in the IN InitialDP CallingPartyNumber
parameter, according to Spanish network rules. Below are a summary of those rules, and the macro’s pseudo-code, VIA diagram, and script XML.
Rules
-
If the
CallingPartyNumber
Nature of Address indicator states that the address is nationally formatted, the expression either strips the "00" international direct dialing prefix (if present), or adds the "34" country code if the address is a 9-digit (Spanish national) number. In any other case the address is left unchanged. -
In the general case this should provide an address starting with "34" followed by a 9-digit national number, such as "34607000001".
-
The macro assigns the normalised address (or the original address if it wasn’t changed) to the user-defined variable
user.normalised-cgpn
. -
If the
InitialDP
does not have aCallingPartyNumber
parameter, no user-defined variable is created. -
This condition always evaluates to
true
.
Pseudo-code
if (calling-party-number is present) {
if (calling-party-number.nature == NATIONAL) {
if (calling-party-number.address starts with "0034") {
user.normalised-cgpn = (calling-party-number.address without "00" prefix)
return true
}
else if (calling-party-number.address is 9 digits long) {
user.normalised-cgpn = ("34" + calling-party-number.address)
return true
}
}
// just use the same value if we can't change it
user.normalised-cgpn = calling-party-number.address
return true
}
else {
return true
}
VIA diagram
The SIS scripting language uses short-circuit boolean evaluation. In this current release of VIA, the order of arguments to If you are relying on the behaviour of short-circuit boolean evaluation (for example to guard an See Macros in the SIS Visual Interaction Architect (VIA) User Guide for information about macros. |
Script XML
<macro xmlns="http://www.opencloud.com/SIS/Macro"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.opencloud.com/SIS/Macro sis-macro-1.6.xsd">
<description>
Normalise the CallingPartyNumber parameter according to Spanish numbering conventions
This macro always returns true
pseduo-code version:
if (calling-party-number is present) {
if (calling-party-number.nature == NATIONAL) {
if (calling-party-number.address starts with "0034") {
user.normalised-cgpn = (calling-party-number.address without "00" prefix)
return true
}
else if (calling-party-number.address is 9 digits long) {
user.normalised-cgpn = ("34" + calling-party-number.address)
return true
}
}
// just use the same value if we can't change it
user.normalised-cgpn = calling-party-number.address
return true
}
else {
return true
}
</description>
<macro-name>Normalise CallingPartyNumber</macro-name>
<macro-vendor>OpenCloud</macro-vendor>
<macro-version>1.0</macro-version>
<macro-expression>
<or>
<!-- either (calling-party-number is present and ...) or true -->
<and>
<!-- calling-party-number is present and we assign a normalised value -->
<present variable="${initial-dp.arg.calling-party-number}"/>
<!-- define the 'normalised' address as equal to the original by default -->
<assign toVariable="${user.normalised-cgpn}" value="${initial-dp.arg.calling-party-number.address.hex}"/>
<or>
<and>
<equal a="${initial-dp.arg.calling-party-number.nature}" b="NATIONAL"/>
<or>
<and>
<string-starts-with source="${user.normalised-cgpn}" prefix="0034"/>
<assign toVariable="${user.normalised-cgpn}">
<string-substring source="${user.normalised-cgpn}" begin-index="2"/>
</assign>
</and>
<and>
<equal>
<string-length source="${user.normalised-cgpn}"/>
<value value="9"/>
</equal>
<assign toVariable="${user.normalised-cgpn}">
<string-prepend source="${user.normalised-cgpn}" prefix="34"/>
</assign>
</and>
</or>
</and>
<!-- force true to be returned in the case no normalisation possible -->
<true/>
</or>
</and>
<!-- force true to be returned in the case a CallingPartyNumber wasn't present -->
<true/>
</or>
</macro-expression>
</macro>