Mapping data using a group element - 7.3

tXMLMap

Version
7.3
Language
English
Product
Talend Big Data
Talend Big Data Platform
Talend Data Fabric
Talend Data Integration
Talend Data Management Platform
Talend Data Services Platform
Talend ESB
Talend MDM Platform
Talend Real-Time Big Data Platform
Module
Talend Studio
Content
Data Governance > Third-party systems > Processing components (Integration) > tXMLMap
Data Quality and Preparation > Third-party systems > Processing components (Integration) > tXMLMap
Design and Development > Third-party systems > Processing components (Integration) > tXMLMap
Last publication date
2024-02-21

Based on Launching a lookup flow to join complementary data, this scenario presents how to set up an element as group element in the Map Editor of tXMLMap to group the output data. For more information about how to group the output data using tXMLMap, see Talend Studio User Guide.

The objective of this scenario is to group the customer id and the customer name information according to the states the customers come from. You need to reconstruct the XML tree view of the Customer output table by considering the following factors:

  • The elements tagging the customer id and the customer name information should be located under the loop element. Thus they are the sub-elements of the loop element.

  • The loop element and its sub-elements should be dependent directly on the group element.

  • The element tagging the state information used as the grouping condition should be dependent directly on the group element.

  • The group element cannot be the root element.

Based on this analysis, the XML structure of the output data should read as follows. The customers node is the root element, the customer node is set as the group element and the output data is grouped according to the LabelState element.

To put a group element into effect, the XML data to be processed should have been sorted, for example via your XML tools, around the element that will be used as the grouping condition. In this example, the customers possessing the same state id should be put together. The input data in the XML file Customer.xml should read as follows:

<?xml version="1.0" encoding="ISO-8859-15"?>
<Customers>
	<Customer RegisterTime="2001-01-17 06:26:40.000">
		<Name>
			<id>1</id>
			<CustomerName>Griffith Paving and Sealcoatin</CustomerName>
		</Name>
		<Address>
			<CustomerAddress>talend@apres91</CustomerAddress>
			<idState>2</idState>
		</Address>
		<Revenue>
			<Sum1>67852</Sum1>
		</Revenue>
	</Customer>
	<Customer RegisterTime="1987-02-23 17:33:20.000">
		<Name>
			<id>3</id>
			<CustomerName>Glenn Oaks Office Supplies</CustomerName>
		</Name>
		<Address>
			<CustomerAddress>1859 Green Bay Rd.</CustomerAddress>
			<idState>2</idState>
		</Address>
		<Revenue>
			<Sum1>1225.</Sum1>
		</Revenue>
	</Customer>
	<Customer RegisterTime="2002-06-07 09:40:00.000">
		<Name>
			<id>2</id>
			<CustomerName>Bill's Dive Shop</CustomerName>
		</Name>
		<Address>
			<CustomerAddress>511 Maple Ave. Apt. 1B</CustomerAddress>
			<idState>3</idState>
		</Address>
		<Revenue>
			<Sum1>88792</Sum1>
		</Revenue>
	</Customer>
	<Customer RegisterTime="1992-04-28 23:26:40.000">
		<Name>
			<id>4</id>
			<CustomerName>DBN Bank</CustomerName>
		</Name>
		<Address>
			<CustomerAddress>456 Grossman Ln.</CustomerAddress>
			<idState>3</idState>
		</Address>
		<Revenue>
			<Sum1>64493</Sum1>
		</Revenue>
	</Customer>
</Customers>