Script
The script element is used to hold user defined script functions that can be called using the transform command.
<script>
Java Script
</script>
Parameters
- Java Script (optional)
- User defined functions.
Remarks
The script can contain any valid Java Script. However, since the script is being held in an XML file, some characters that would normally be used in a Java Script will not be valid. For example, the following will cause an error:
if (a < b)
since the less than sign is not allowed in this part of an XML file. There are two solutions to this:
- Use the XML equivalents of
these characters. For example,
<
and>
can be used in place of<
and>
respectively. - Put the script code in a
CDATA
section. For example:
<script>
<[CDATA[
:
if (a < b>
:
]]>
</script>
Example
<!--Checks the account code number and changes it depending on the range it is in.-->
<script>
<![CDATA[
function modifyAccountCode(account_number)
{
if (account_number > 64000 && account_number < 64999)
{
return 64000;
}
return account_number;
}
]]>
</script>
<transform>
<target>SSTSInput/Payload/Ledger/AccountCode</target>
<function name="modifyAccountCode">
<param>SSTSInput/Payload/Ledger/AccountCode</param>
</function>
</transform>