The XML Generator Transformation in Informatica is an Active, and Connected transformation. This transformation is useful to generate XML files inside a pipeline. In this article we will show you, How to use XML Generator Transformation in Informatica to generate XML file from Database table with example.
For this example, we are going to use the below show data (Customer record table)
XML Generator Transformation in Informatica Example
In this article we will show you, How to use this XML Generator Transformation in Informatica to generator XML file using the SQL Database table. Before we start configuring, First let me connect with the Informatica repository service. In order 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.
TIP: Here you have to provide the Admin Username and password that you specified while installing the Informatica Server.
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 Customer table from 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 Target. In this example our task is to create a XML File. So, go to Targets menu and select the Import XML Definition option as show below. By this you can define the XML Definition inside a Target definition.
Ideal Approach – Go to Targets menu and select the Create option as show below.
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 are done, Please click on the Create button to create 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 scissors symbol) as shown below. This will open the empty row to add Column Name, Data Type
From the below screenshot you can observe that, we added one XML_Output column of string data type.
Now you can see the target table with one column name. This is the column that will handle the XML file.
Step 3: Create a Mapping for XML Generator Transformation in Informatica
To create a new mapping, Please navigate to Mappings menu in Menu Bar, and select the Create.. option.
This will open the Mapping Name window to write 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, Power Center designer will automatically create the source qualifier for you. I suggest you to refer Source Qualifier Transformation article.
Step 3(a): Create a XML Generator Transformation in Informatica
In order to create a XML generator Transformation, Please navigate to Transformation menu in Menu Bar and select the Create.. option as we shown below.
Once you click on the Create.. option, Create Transformation window will be opened as we shown below. Please select the XML Generator Transformation from 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 local file system then select this option.
URL: Select the XML defintion 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 any XSD file, and if you want to use the SQL table present in the informatica Source definition then select this Non-XML Sources option. For this example, we are going to use the Customerrecord table present in the Source definition.
This will open a 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 second page. In this example we want to save our XML file using Entity relation so, we are selecting first option.
Once you click on the Finish button, XML Generator Transformation will be 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 Targets folder to the mapping designer. Next, connect the XML Generator Transformation data output to XML_Output field in 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 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 workflow.
In this example we will create the Workflow manually. To do so, Please navigate to Workflows Menu and select the Create option.
This will open Create Workflow window as shown below. Please provide the unique name (wf_XMLGenerator) and leave the default settings.
Once we created the workflow, our next step is to create 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 example we created a Non-reusable Session. In order to create Non-reusable Session, Please navigate to Tasks Menu and select the Create option as shown below.
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 will be 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 Sopurce)
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 present in the Targets folder.
- Output File Directly: Informatica will use the default directory but you can change the directory by giving 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 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 a XML file from source table or not.
You can see the data inside the xmlcustomer_records xml file.
Thank You for Visiting Our Blog