19 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 19-1 Access request or response body

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

Table 19-2 Access request or response headers

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

Table 19-3 Access response body as string

Access response body as string
Syntax $bodyAsString

Table 19-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 19-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 19-6 Null Check

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

Table 19-7 Random Number

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

Table 19-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 19-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 19-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 19-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 19-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 19-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 19-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 19-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 19-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 19-17 XML parsing

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

Table 19-18 JSON parsing

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

Table 19-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 19-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 19-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.