Versions Compared
Key
- This line was added.
- This line was removed.
- Formatting was changed.
You can set various properties of a target element. The Properties menu comprises of various properties, which are outlined in the table below.
Property | Description |
---|---|
For Each | Sets the For Each property for the destination element. It is used to repeat occurrences of a destination element depending on the total occurrences of a source element in the source file. |
Sorting | Sets the Sorting rules for the destination element. It allows you to view or remove sorting rules for the destination element. |
Disable-Output-Escaping | Sets the disable-output –escaping property for the target element. It is used to include this property under the 'value-of' element in the generated XSL. By default, this property is set as 'no'. |
For Each
The For Each property is used to repeat the occurrences of a target element or node, depending on the total occurrences of a source element or a node in the source file. For example, an XML layout with a node customer has three elements, first_name, last_name, and state. This layout is used both at the source and at the destination end.
Suppose, the source file has 10 occurrences of the customer. Applying the For Each property on the destination node customer, for the source node customer, generates an output file containing 10 occurrences of the customer in it.
- If For Each property is not used, an output file is generated with only one occurrence of customer in it.
- For Each and Apply Template both cannot be used simultaneously on one node.
Follow the steps below to set the For Each property:
Info |
---|
Ensure that the source and destination layout are loaded and all their elements are listed under their respective nodes. |
Click the destination element for which you want to set the For Each property.
Click the Mapping Expression tab.
Click the Properties menu, select For Each, and then double-click the source element using which you want to apply the For Each property.
This displays the entire path of the source element in the mapping expression area.Note You can set the For Each property on more than one source element. You can use the | character as a separator between the XPath of each source element.
Tip Once the For Each property is applied to a target element, the letter (F) is displayed next to the target element.
To remove the For Each property, follow the steps below:
- Click More menu icon for the destination element, and then select the Remove Mappings option.
- On the Remove Options screen, select the Remove For Each check box.
- Click Remove.
Setting Sorting rules
You can set sorting rules for a target element. It is used to sort value of elements in the generated output. While generating the output XML, the value of elements can be sorted either in ascending or descending order. For example, records of the employee can be sorted based on their salaries. Below is the sample Input XML file.
<? xml version = "1.0" encoding = "UTF-8" ?> -< employees > -< employee attribute = "14" attribute1 = "15" > < TESTCASENO >TESTCASENO1</ TESTCASENO > < DESCRIPTION >DESCRIPTION1</ DESCRIPTION > < NAME >John</ NAME > < ADDRESS >Address1</ ADDRESS > < EMAILID >EMAILID1</ EMAILID > < PHONENO >PHONENO1</ PHONENO > < DOB >DOB1</ DOB > < DEPT >DEPT1</ DEPT > < SALARY >10000</ SALARY > < DOJ >DOJ1</ DOJ > < DESIGNATION >DESIGNATION1</ DESIGNATION > < AGE >34</ AGE > </ employee > -< employee attribute = "14" attribute1 = "15" > < TESTCASENO >TESTCASENO2</ TESTCASENO > < DESCRIPTION >DESCRIPTION2</ DESCRIPTION > < NAME >David</ NAME > < ADDRESS >ADDRESS2</ ADDRESS > < EMAILID >EMAILID2</ EMAILID > < PHONENO >PHONENO2</ PHONENO > < DOB >DOB2</ DOB > < DEPT >DEPT2</ DEPT > < SALARY >8000</ SALARY > < DOJ >DOJ2</ DOJ > < DESIGNATION >DESIGNATION2</ DESIGNATION > < AGE >45</ AGE > </ employee > -< employee attribute = "14" attribute1 = "15" > < TESTCASENO >TESTCASEN3</ TESTCASENO > < DESCRIPTION >DESCRIPTION3</ DESCRIPTION > < NAME >Ricky</ NAME > < ADDRESS >ADDRESS3</ ADDRESS > < EMAILID >EMAILID3</ EMAILID > < PHONENO >PHONENO3</ PHONENO > < DOB >DOB3</ DOB > < DEPT >DEPT3</ DEPT > < SALARY >15000</ SALARY > < DOJ >DOJ3</ DOJ > < DESIGNATION >DESIGNATION3</ DESIGNATION > < AGE >36</ AGE > </ employee > </ employees > |
The image below shows the Output XML after sorting.
<? xml version = "1.0" encoding = "UTF-8" ?> -< employees xmlns:java = "http://xml.apache.org/xslt/java" xmlns:str = "http://exslt.org/strings" > -< employee attribute = "" attribute1 = "" > < TESTCASENO >TESTCASEN3</ TESTCASENO > < DESCRIPTION >DESCRIPTION3</ DESCRIPTION > < NAME >Ricky</ NAME > < ADDRESS >ADDRESS3</ ADDRESS > < EMAILID >EMAILID3</ EMAILID > < PHONENO >PHONENO3</ PHONENO > < DOB >DOB3</ DOB > < DEPT >DEPT3</ DEPT > < SALARY >15000</ SALARY > < DOJ >DOJ3</ DOJ > < DESIGNATION >DESIGNATION3</ DESIGNATION > < AGE >36</ AGE > </ employee > -< employee attribute = "" attribute1 = "" > < TESTCASENO >TESTCASENO1</ TESTCASENO > < DESCRIPTION >DESCRIPTION1</ DESCRIPTION > < NAME >John</ NAME > < ADDRESS >Address1</ ADDRESS > < EMAILID >EMAILID1</ EMAILID > < PHONENO >PHONENO1</ PHONENO > < DOB >DOB1</ DOB > < DEPT >DEPT1</ DEPT > < SALARY >10000</ SALARY > < DOJ >DOJ1</ DOJ > < DESIGNATION >DESIGNATION1</ DESIGNATION > < AGE >34</ AGE > </ employee > -< employee attribute = "" attribute1 = "" > < TESTCASENO >TESTCASENO2</ TESTCASENO > < DESCRIPTION >DESCRIPTION2</ DESCRIPTION > < NAME >David</ NAME > < ADDRESS >ADDRESS2</ ADDRESS > < EMAILID >EMAILID2</ EMAILID > < PHONENO >PHONENO2</ PHONENO > < DOB >DOB2</ DOB > < DEPT >DEPT2</ DEPT > < SALARY >8000</ SALARY > < DOJ >DOJ2</ DOJ > < DESIGNATION >DESIGNATION2</ DESIGNATION > < AGE >45</ AGE > </ employee > </ employees > |
The Sorting rules can be set only for record where For Each Mapping or Apply Template is used. The <xsl:apply-templates> element applies a template to the current element or to the child nodes of the current element, when the parent elements of source and target schemas are mapped.
Follow the steps below to set the sorting rules: Anchor set the sorting rules set the sorting rules
Info |
---|
Ensure that the source and destination layout are loaded and all their elements are listed under their respective nodes. |
Click the destination element for which you want to set the sorting rule.
Click the Mapping Expression tab.
Click the Properties menu, select Sorting, and then double-click the source element based on which you want to apply sorting.
Select the data type as either Text or Number in the Data Type field. This specifies how the input value is to be interpreted. By default, Text is selected.
Select the sorting order as Ascending or Descending in the Order field. By default, Ascending is selected.
Click icon to save the sorting rule.
The letter (SR) is displayed next to the sorted target element. This signifies that the target element has been sorted based on the specified source element.Tip More than one sorting can also be applied to a single target element. For example, if salary of two employees is same, they can be further sorted out based on their age. To apply more sorting rules, click Add New Sorting Rule and follow the steps 1 through 6.
To remove the sorting rule, follow the steps below:
- Click More menu icon against the destination element, and then select the Remove Mappings option.
- On the Remove Options screen, select the Remove Sorting Rules check box.
- Click Remove.
Panel | ||||
---|---|---|---|---|
| ||||
What's newBest practicesTraining guidesFrequently asked questionsAdeptia Connect APIsAdeptia security report |