20 Transformation Type

This topic provides the information about the transformation types.

Velocity

Velocity is a Java-based template engine. It is used to generate XML files, SQL, PostScript, and most other text-based formats.

Note:

In Routing Hub, velocity is used to generate JSON and XML files.

Table 20-1 Access request or response body

Access request or response body
Syntax $body.fieldName
Example $body.branchCode

Table 20-2 Access request or response headers

Access request or response headers  
Syntax $headers["fieldName"][0]
Example $headers["branchCode"][0]

Table 20-3 Access response body as string

Access response body as string
Syntax $bodyAsString

Table 20-4 Date Conversion (Routing Hub’s custom date conversion)

Date Conversion (Routing Hub’s custom date conversion)
Syntax $dateUtil.convert(inputDate, fromPattern, toPattern)
Parameters
inputDateString
fromPattern : String
toPattern : String
Returns String
Reference Date patterns: https://docs.oracle.com/javase/8/docs/api/java/text/SimpleDateFormat.html

Table 20-5 Returns default Value if input value is null or empty

Returns default Value if input value is null or empty
Syntax $custom.defaultValue(inputValue, defaultValue)
Parameters
inputValue : Object
defaultValue : String
Returns Object

Table 20-6 Null Check

Null Check
Syntax $custom.isNull(inputValue)
Parameters inputValue : Object
Returns boolean

Table 20-7 Random Number

Random Number
Syntax $mathUtil.getRandom()
Returns Object of Random class (java.util.Random)

Table 20-8 Xml Tool

Xml Tool
Syntax $xml.methodName()
Reference https://velocity.apache.org/tools/3.1/apidocs/org/apache/velocity/tools/generic/XmlTool.html

Table 20-9 Date Tool

Date Tool
Syntax $date.methodName()
Reference https://velocity.apache.org/tools/3.1/apidocs/org/apache/velocity/tools/generic/DateTool.html

Table 20-10 Json Tool

Json Tool
Syntax $json.methodName()
Reference https://velocity.apache.org/tools/3.1/apidocs/org/apache/velocity/tools/generic/JsonTool.html

Table 20-11 Math Tool

Math Tool
Syntax $math.methodName()
Reference https://velocity.apache.org/tools/3.1/apidocs/org/apache/velocity/tools/generic/MathTool.html

Table 20-12 Number Tool

Number Tool
Syntax $number.methodName()
Reference https://velocity.apache.org/tools/3.1/apidocs/org/apache/velocity/tools/generic/NumberTool.html

Table 20-13 Escape Tool

Escape Tool
Syntax $esc.methodName()
Reference https://velocity.apache.org/tools/3.1/apidocs/org/apache/velocity/tools/generic/EscapeTool.html

Table 20-14 Serialization of object into its equivalent Json representation

Serialization of object into its equivalent Json representation
Syntax $custom.toJson(src)
Parameters src - Object
Returns String

Table 20-15 Get additional field's value based on fieldname

Get additional field's value based on fieldname
Syntax $custom.getFieldValueById(jsonString, fieldname)
Parameters
jsonString : String
fieldname : String
Returns String

Table 20-16 Get list of additional fields based on fieldname prefix

Get list of additional fields based on fieldname prefix
Syntax $custom.getAdditionalFieldSetByType(jsonString,prefixval)
Parameters
jsonString - String
prefixval - String
Returns List<AdditionalAttributes>

Table 20-17 XML parsing

XML parsing
Syntax $custom.parseXml(xmlString)
Parameters xmlString : String
Returns Object

Table 20-18 JSON parsing

JSON parsing
Syntax $custom.parseJson(jsonString)
Parameters jsonString : String
Returns Object

Table 20-19 Get expiry time from token of expiry time

Get expiry time from token of expiry time
Syntax
$custom.getExpiryTime(token)
$custom.getExpiryTime(token, expiryTimeField)
Parameters
token : String
expiryTimeField : String (Default value: exp)
Returns String

Table 20-20 Base64 encoding with padding option

Base64 encoding with padding option
Syntax $custom.encodeToBase64(input,paddingFlag)
Parameters
input : String / Byte array
paddingFlag : Boolean
Returns String

Table 20-21 Generate client assertion

Generate client assertion
Syntax
$custom.generateClientAssertion(clientId, kId)
$custom.generateClientAssertion(clientId, kId, validitySeconds)
$custom.generateClientAssertion(clientId, kId, validitySeconds, keyAlias)
$custom.generateClientAssertion(clientId, kId, validitySeconds, keyAlias, algorithm)
$custom.generateClientAssertion(clientId,  kId , validitySeconds, keyAlias, algorithm, tokenEndpointUrl)
Parameters
clientId : String
kId : String
validitySeconds  : Integer (Default value:  300)
keyAlias : String
algorithm : String (Default value:  RS256)
tokenEndpointUrl : String
Returns String
  • If issue occurred with hyphen in velocity template of Request or Response Transformation, then use get method.

    Example:

    <FCUBS_BODY>
       <Customer-IO>
         <CUSTNO>003942</CUSTNO>
       </Customer-IO>
    </FCUBS_BODY>

    If $in.FCUBS_BODY.Customer-IO.CUSTNO does not work , use $in.FCUBS_BODY.get("Customer-IO").CUSTNO to get customer number.

XSLT

XSLT is a language for transforming XML documents into other XML documents, or other formats such as HTML for web pages, plain text or XSL formatting objects, which may subsequently be converted to other formats, such as PDF, PostScript and PNG.

Note:

In Routing Hub, XSLT is used to transform arbitrary XML to JSON.

JSLT

JSLT is a complete query and transformation language for JSON.