The XML Generator Transformation in Informatica is an Active and Connected transformation. This transformation is useful in generating XML files inside a pipeline.
In this article, we will show you how to use XML Generator Transformation in Informatica to generate an XML file from the Database table with an example.
For this Informatica XML Generator Transformation example, we are going to use the below show data (Customer record table)
XML Generator Transformation in Informatica Example
Let’s see how to use this XML Generator Transformation in Informatica to generate an XML file using the SQL Database table. Before we start configuring, First, let me connect with the Informatica repository service.
To do so, we have to provide the Informatica Admin Console credentials. So, Please provide the appropriate Username and Password, and click the Connect button.
Step 1: Source Definition for XML Generator Transformation in Informatica
Once you connected successfully, please navigate to Source Analyzer and define your Sources. In this example, we are using the Customer table from the SQL Server database as our source definitions. Please refer Database Source in Informatica to understand the steps involved in creating source definition
Step 2: Create Target Definition for XML Generator Transformation in Informatica
First Approach – Please navigate to Target Designer to define the Informatica XML Generator Transformation Target. In this example, our task is to create an XML File. So, go to the Targets menu and select the Import XML Definition option. By this, you can define the XML Definition inside a Target definition.
Ideal Approach – Go to Targets menu and select the Create option.
Once you select the Create option, a new window called Create Target table will be displayed as shown below. Please provide a unique name for the target, and select the database type as Flat File.
Once you complete, Please click on the Create button to create a new empty table in our PowerCenter Target Designer.
Double-click on the newly created target table. Next, go to the Columns Tab to add a new column. Please select the first button (before the scissors symbol). It opens the empty row to add Column Name, Data Type
From the below screenshot, you can observe that we added one XML_Output column of a string data type.
Now you can see the target table with one column name. It is the column that handles the XML file.
Step 3: Create a Mapping for XML Generator Transformation in Informatica
To create a new mapping for Informatica XML Generator Transformation, Please navigate to Mappings menu in Menu Bar, and select the Create.. option.
It will open the Mapping Name window to write a unique name for this Mapping. Let me write m_xml_generator and click OK button.
TIP: Please refer Informatica Mapping article to understand the procedure to create Mapping
Drag and drop the Customer record source definitions from Sources folder to the mapping designer. Once you drag the Source, the Power Center designer will automatically create the source qualifier for you. I suggest you refer to the Source Qualifier Transformation article.
Step 3(a): Create a XML Generator Transformation in Informatica
To create an XML generator Transformation, Please navigate to the Transformation menu in Menu Bar and select the Create.. option.
Once you click on the Create.. option, Create transformation window opened. Please select the XML Generator Transformation from the drop-down list and specify the unique name (XML_GenCustomer) and click on Create button
Once you click on the Create.. button, a new window called Import XML Definition will be opened as shown below. Here, you have to specify the XSD or XML definition for this XML file.
Local File: If the XSD file is in the local file system, then select this option.
URL: Select the XML definition file at particular URL
Non-XML Targets: If the source is a Non-XML file, and if it is present in the Informatica Target definition
Non-XML Sources: If you don’t have an XSD file and want to use the SQL table in the Informatica Source definition, then select this option. For this example, we are going to use the Customerrecord table present in the Source definition.
It will open an XML wizard. Click Next button
Every XML file has to be processed using a Valid XML Definition (or XSD). Please define the XML definition in the second page. In this example, we want to save our XML file using Entity relation. So, we are selecting the first option.
Once you click on the Finish button, XML Generator Transformation added to the mapping designer.
Now let me add all the fields from Source Qualifier to XML Generator Transformation
Next, Drag and drop the target definition from the Targets folder to the mapping designer. Next, connect the XML Generator Transformation data output to the XML_Output field in the Target table.
Before we close the Mapping, Let us Save, and Validate the mapping by going to Mapping Menu bar, and select the Validate option.
Step 4: Create a Workflow for XML Generator Transformation in Informatica
After we finish creating the Mapping, we have to create the workflow for it. Power Center Workflow manager provides two approaches to create a workflow.
In this Informatica XML Generator Transformation example, we will create the Workflow manually. To do so, Please navigate to Workflows Menu and select the Create option.
It will open the Create Workflow window. Please provide the unique name (wf_XMLGenerator) and leave the default
Once we created the workflow, our next step is to create a session task for our mapping.
Step 4(a): Create Session for XML Generator Transformation in Informatica
There are two types of sessions in Informatica:
For this Informatica XML Generator Transformation example, we created a Non-reusable Session. To create Non-reusable Session, Please navigate to Tasks Menu and select the Create option.
Please provide a unique name for this session. Here, we are naming it as s_XMLGenerator. Once you click on the Create button, a new window called Mappings opened.
Here you have to select the mapping that you want to associate with this session i.e., m_xml_generator.
Double click on the Session task will open the Edit Tasks window. Within the Mappings tab, we have to configure the Source, and Target Connections. First, let us configure the source connections by clicking on the SQ_CustomerRecord source present in the Sources folder.
Within the Connections, click on the Arrow button beside the Relational type, and select the source table database (Informatica Source)
Now you can see the Informatica Source as the relational connection
Now, we have to configure the Target Connection. So, let us configure the target connection by clicking on the XMLCustomer_Records in the Targets folder.
- Output File Directly: Informatica will use the default directory, but you can change the directory by giving the full path.
- Output filename: Please change the extension to xml
You can use the Transformation properties to Validate or Format the Output (generated XML) file
Next, navigate to Workflows Menu and select the Validate option to validate the Workflow.
Now, Let me start the Informatica XML Generator Transformation Workflow by selecting the Start Workflow option in Workflows Menu.
Let us open the default target location of the Informatica to check whether we successfully created an XML file from the source table or not.
You can see the data inside the xmlcustomer_records xml file.