Using Mapping Functions
You can map source and destination layout elements using the various mapping functions built-in the Web Mapper. All these mapping functions comprise of sub-functions, which are used to map elements.Â
Some mapping functions require the use of constant values for mapping elements. For this, you need to add the constant node to the Mapping Expression Area. Apart from these Mapping Functions, you can also use inbuilt mapper utility classes and global methods available in the Web Mapper to map the elements. Visit Mapper Utility page to know how to use utility classes.
Using Math FunctionÂ
The Math mapping function enables you to map elements by performing simple mathematic operations. It comprises of various sub-functions, which are listed in the table below. Â
Mapping Function | Sub-Functions | Description | Example |
---|---|---|---|
Math          | Add | Adds two numeric elements. | (10) + (5)returns 15 |
Ceiling | Rounds a passed number to the smallest integer that is greater than or equal to the passed number. | Ceiling(33.9)returns 34 | |
Division | Divides two numeric elements. | (100)Â div(5)Â returns 20 | |
Floor | Rounds a passed number to the largest integer that is not larger than the passed number. | floor(33.9)returns 33 | |
Mod | Returns the remainder of a division between two numeric values. | (50)Â mod(3)Â returns 2 | |
Multiply | Multiplies two numeric elements. | (10)Â *Â (5)returns 50 | |
Round | Rounds a passed number to the nearest integer. | round(4.6)returns 5 | |
Subtract | Subtracts one numeric value from other. | (10) – (5)returns 5 | |
Number | Converts parameter to a number. | number("-17.3")returns -17.3 | |
Format number | Transforms input data into a specific format. By default it rounds off the value by considering only the digits before the decimal point. You may, however, specify the number of decimal places to be considered by increasing the count of hashes (#), it rounds off the last digit defined after decimal point, see corresponding example. The specific format allowed is decimal. This function can be used only if the target node is of string data type. | format-number(12.5746, '#.###')returns 12.575 |
You can use the required sub-function of Math mapping function to map elements. The process of using the Math function is the same for all its sub-functions.
Using String FunctionÂ
The String mapping function enables you to map elements by manipulating strings. It comprises of various sub-functions, which are listed in the table below. Â
Mapping Function | Sub-Functions | Description | Example |
---|---|---|---|
String            | Concat | Concatenates the second string after the first string. | concat ('Jane', 'Brown') |
Substring | Returns the sub string from the string starting from the specified position and of the specified length. When using this function, you always start counting its position from 1. This implies that the second argument (position) is always greater than or equal to 1. | substring ('abcdef' ,3, 4) | |
String | Returns the string value of the argument. | string ('1000') returns the string 1000 | |
Translate | Translates each occurrence of the first argument in the specified string to the second argument. Both the arguments must consist of one or equal number of characters. | translate ('alphabet', 'a','t') | |
Substring-after | Returns the string after the specified argument from the string. | substring-after('print=yes', '=')Â returns yes | |
Substring-before | Returns the string before the specified argument from the string. | substring-before('print=yes', '=')Â returns print | |
Starts-with | Returns true if the string starts with the specified argument or false otherwise. | starts-with ('Sales', 'S') | |
String-length | Returns the length of the specified string. | string-length('adeptia') | |
Contains | Returns true if the string contains the specified argument or false otherwise. | contains ('adeptia', 'tia') | |
Normalize-space | Removes leading and trailing white space (space, tab and new line) from a string, and replaces internal sequences of white space with a single space character. | normalize-space (' Adeptia Inc ' ) returns Adeptia Inc | |
Name | Returns the name of the source node and field name on which mapping is currently done. | If the context node is an element named<ms:schema>, then | |
Local-name | Returns name with the name prefix. If no prefix was specified, then name and local name are same. | If context node is an element named<ms:schema>, then |
You can use the required sub-function of String mapping function to map elements. The process of using the String function is the same for all its sub-functions.Â
Using Date Function
The Date mapping function enables you to map elements by generating dates in specific formats. It also returns the current date and the difference between two dates. It comprises of various sub-functions, which are listed in the table below.
Â
All Date functions are applicable, only for XML Schemas at source and target.
Â
Mapping Function | Sub-Functions | Description | Example |
---|---|---|---|
Date | Date-Format | This is a customized mapping function. | date-format (employee/ 1998-03-31, 'yyyy-MM-dd', 'dd-MM-yyyy') |
 | Date -Difference | Generates the | date-difference('12-08-2006','dd-MM-yyyy','12-08-2005', 'dd-MM-yyyy') |
 | Current Date | Returns the current system date in Month-day-year format. | current date ('MM-dd-yyyy') |
Â
You can use the required sub-function of Date mapping function to map elements. The process of using the Date function is the same for all its sub-functions.Â
Using Aggregation Functions Â
The Aggregation function enables you to map elements by aggregating or counting the values of all nodes in an element. It comprises of various sub-functions, which are listed in the table below.
Mapping Function | Sub-Functions | Description | Example |
---|---|---|---|
Aggregation | Sum | Returns total of all values under all nodes of the specified element. | Sum (Age) returns the sum of all Age elements under the specified node. |
 | Count | Returns the total number of nodes for the specified element. | Count (Age) returns the total number of records under the Age element. |
 | Position | Returns the position of the current context node in the specified element. | position() returns 1 for the first node, 2 for second node and so on. |
 | Key | Returns matched records using two parameters: | Refer to the Using Key Function section. |
Â
You can use the required sub-function of Aggregation mapping function to map elements. The process of using the Aggregation function is the same for all its sub-functions.Â
Using Conditional FunctionÂ
The Conditional mapping function enables you to map elements by building conditional expressions. It comprises of various sub-functions, which are listed in the table below.Â
Â
Mapping Function | Sub-Functions | Description | Example |
---|---|---|---|
Conditional | IF Conditions | This function comprises of two sub functions: | |
 | For Filtering Records | Filters the records/elements on basis of the specified condition. Note: If filtering is applied at the parent record, IFF condition filters the records on the basis of given condition, and ignores the 'Value'.  If you apply a condition at the child of parent, it returns the 'Value', given that IFF condition gets satisfied. | IFF CONDITION {Age=25} Value= [100] |
 | For Mapping To Elements | Returns a value if the specified condition is true. | IF CONDITION {Age=25} Value= [100] |
 | When Condition | Returns a particular value if the specified condition is true, else it returns another value. | WHEN Condition {contains (Email_ID, '@')} Value= [100] Otherwise Value= [200] |
 | Select Query | This is a customized mapping function. | SELECT FIELD = [Value1] FROM DB.TAB = [Value2].[Value3] WHERE {Condition} SELECT FIELD = [EMPNO] FROM DB.TAB = [oracle_databaseserver].[EMP] WHERE {[ENAME= 'Smith'] AND [AGE = 28]} |
 | Sequence | This is a customized mapping function. | Sequence {10, 20} |
Â
Some conditional sub-functions are not included in the Web Mapper screen, but are implemented by extending the 'IF' and 'When' conditions. These sub-functions are listed in Table below.
Â
Mapping Function | Sub-Functions | Description | Example |
---|---|---|---|
IF Condition | Nested IF | Contains IF condition inside the value of previous IF condition. | IF CONDITION {Age=25} Value= [IF CONDITION {#Designation= 'Manager'} Value = IF CONDITION {Salary= 20000} Value = [100]]] |
When Condition | Nested When | Contains When condition inside the value of previous When condition. |
|
IF and When Condition | IF and When conditions return Boolean | Returns value based on the function used as whether the condition returns True or False. |
|
IF and When Condition | Mixed | Contains IF condition inside the value part of When condition or vice versa. | WHEN CONDITION {/employees/employee/Salary=50000} Value= IF CONDITION {/employees/employee/Designation= Project Manager} Value = ['100'] OTHERWISE Value = ['200'] |
IF Condition | Multiple IF | Contains IF conditions placed sequentially, with each IF having its value part. | IF CONDITION {Age=25} Value= ['500'] IF CONDITION {Designation= 'Manager'} Value = [1000] |
When Condition | When condition with more than one conditions in it. | Contains When condition containing logical operators like and/not to make multiple conditions inside the When condition. | WHEN CONDITION {/employees/employee/Age=25 and /employees/employee/Designation=Manager} Value= ['100'] OTHERWISE Value = ['200'] |
IF Condition | IF condition with more than one conditions in it. | Contains IF condition containing logical operators like and/not to make multiple conditions inside the IF condition. | IF CONDITION {/employees/employee/Age=25 and /employees/employee/Designation=Manager} Value= ['100'] |
Â
You can use the required sub-function of Conditional mapping function to map elements. The process of using the Conditional function is the same for all its sub-functions.Â
 Using Axis Function
 The Axis function contains a list of advance XSL functions that are used to map elements only when the For Each function is applied on the Target node. It comprises of various sub-functions, which are listed in the table below.Â
Mapping Function | Sub-Functions | Description | Example |
---|---|---|---|
Axis            | File Path – XPath | This is a customized mapping function. | FilePath ['C:/correct_file.xml'] XPath {'/employees/employee/Name'} |
Self | Returns the element which is the context node itself. | Self::Employee | |
Child | Returns the element which is the child of the context node. | Child::Name | |
Parent | Returns the element, which is the parent (if any) of the context node. | Parent::Name | |
Following-sibling | This axis contains all the following siblings of the context node. It returns the first occurrence of the element/attribute in the next sibling of the context node. If the context node is an attribute node or namespace node, then this axis is empty. | following-sibling: employee/Name | |
Ancestor | Returns the element which is the ancestor of the context node. This axis always includes the root node, unless the context node is the root node. | Ancestor::Name | |
Ancestor-or-self | This axis contains the context node and the ancestors of the context node. It always includes the root node. It returns the context node or ancestors of the context node. | ancestor-or-self::employees/@val | |
Preceding-sibling | This axis contains all the preceding siblings of the context node. It returns the first occurrence of the element/attribute in the preceding sibling of the context node. If the context node is an attribute node or namespace node, then this axis is empty. | preceding-sibling: employee/Name | |
Descendant | Returns the element which is the descendant of the context node. This axis does not contain attribute nodes. | descendant::Name | |
Descendant-or-self | This axis contains the context node and the descendants of the context node. It returns the context node or descendants of the context node. | descendant-or-self::employees/salary | |
Generate-id | Generates a unique id for the element/attribute specified by the XPath argument. | generate-id (employees/employee/Name) | |
Current | Removes all tags from the specified xml file and returns the data. | current() |
You can use the required sub-function of Axis mapping function to map elements. The process of using the Axis function is the same for all its sub-functions.
Using Boolean Function
The Boolean mapping function enables you to map elements by applying various logical operators in building Boolean expressions. It comprises of various sub-functions, which are listed in the table below.
Mapping Function | Sub-Functions | Description | Example |
---|---|---|---|
Boolean        | Equal | Returns TRUE the first variable argument is equal to the second variable argument. | (5) = (5)returns true |
Not Equal | Returns TRUE the first variable argument is not equal to the second variable argument. | (5) != (50)returns true | |
Greater Than | Returns TRUE the first variable argument is greater than the second variable argument. | (5)> (3)returns true | |
Less Than | Returns TRUE the first variable argument is less than the second variable argument. | (5) < (8)returns true | |
Greater than Equal | Returns TRUE the first variable argument is greater than or equal to the second variable argument. | (5)>= (5)returns true | |
Less than Equal | Returns TRUE the first variable argument is less than or equal to the second variable argument. | (5) <= (8)returns true | |
Or | Returns TRUE if either of the two variable arguments evaluate to TRUE otherwise FALSE. These variable arguments can only be of Boolean data type. Hence, their value can either be TRUE or FALSE only. | (True) Or (True) returns true | |
And | Returns TRUE if both of the two variable arguments evaluate to TRUE otherwise FALSE. These variable arguments can only be of Boolean data type. Hence, their value can either be TRUE or FALSE only. | (True) And (True) returns true |
 A Boolean sub-function is always used in conjunction with a Conditional function.Â
Using Context Functions
The Context mapping function enables you to map elements by setting or getting the value of process flow context variables.  It comprises of various sub-functions, which are listed in the table below.
Mapping Function | Sub-Functions | Description | Example |
---|---|---|---|
Context | Set-Context | This is a customized mapping function. |
|
 | Get-Context | This is a customized mapping function. | get-context ('index', '100') |