20 Transformation Type
This topic provides the information about the transformation types.
Velocity
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 | |
| 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 | |
| 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 | |
| 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 | |
| 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 | |
| Parameters | |
| Returns | String |
Table 20-20 Base64 encoding with padding option
| Base64 encoding with padding option | |
|---|---|
| Syntax | $custom.encodeToBase64(input,paddingFlag) |
| Parameters | |
| Returns | String |
Table 20-21 Generate client assertion
| Generate client assertion | |
|---|---|
| Syntax | |
| Parameters | |
| 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.CUSTNOdoes not work , use$in.FCUBS_BODY.get("Customer-IO").CUSTNOto 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.