Friday, February 13, 2015

Serializer in Data Transformation in Informatica - XML File to Comma Delimited Flatfile


Serializer is opposite to parser - it converts XML to other formats like Microsoft Excel, text document or an HTML document. You can create a Serializer in two ways - Invert the configuration of an existing Parser or Edit the Script and insert the Serializer component. It is usually easier to create a Serializer than a Parser because the XML is completely structured. The structure makes it easy to identify the required data and write it, in a sequential procedure, to the output.

Serializer contains anchors that are analogous to the anchors that we use in the parser, but work in opposite direction. Serialization anchors read XML data and write the data to locations in the output document. The most important serialization anchors are ContentSerializer and StringSerializer.

ContentSerializer writes the content of a specified data holder to the output document. It is the inverse of a Content anchor, which reads content from a source document.

StringSerializer writes a predefined string to the output. It is the inverse of a Marker anchor, which finds a predefined string in a source document.

Serializer executes the serialization anchors in the sequence of their definitions. Serialization anchors write data sequentially, always appending it to the end of the output document.

In this Blog, We will convert a flat file in XML format to comma delimited flat file. The XML file that we use as example source is given below:

<?xml version="1.0" encoding="windows-1252"?>
<EmpPdf>
<FirstName>Chris</FirstName>
<LastName>Boyd</LastName>
<Department>HR</Department>
<StartDate>2009-10-11</StartDate>
</EmpPdf>

The XSD is same as we used in the Parser.  In the Serializer, we will use the output of the Parser(XML file) as source and convert it to Comma Delimited Flatfile.


If you have  any questions, feel free to leave comments on this page and I would get back as soon as I can.

16 comments:

  1. Nice visualization of serializer in data transformation

    http://www.tekclasses.com/courses/etl/informatica-training-in-bangalore/

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. Hi Hema, Your Tutorials are very helpful, but I am stuck at one point, in both the videos (1. PDF to XML and 2. XML to FLAT FILE) you have not shown as how the input source which is created using a PDF file or in the other video using a XML file was moved to the mapping just before the data processor transformation. ...... Online help for Powercenter Express is too little available, I can do the same with no problem in Enterprise power center 9.x version, but cant figure out here

    ReplyDelete
  4. Thanks Hema and Ankit, I am also getting struck the same. I could not able to find out how can use Xml as a source in Informatica developer. At the end of your video explains that from read transformation output to xml then using data processor to csv file. Can any one help me little briefly how to assign the xml as source then how to load to csv file in informatics developer ? Thanks in advance.

    ReplyDelete
  5. Hi ,
    when i tried this i got the below error message:
    "Failed to serialize my serializer
    Failed to process XML document because of an unrecognized root tag"

    ReplyDelete
  6. Just want to say your article is as astounding. The clarity in your post is simply nice and i could assume you're an expert on this subject. Fine with your permission allow me to grab your RSS feed to keep up to date with forthcoming post. Thanks a million and please carry on the rewarding work.
    afp print format

    ReplyDelete
  7. Hi, I have been following this to fetch data from an html file.
    However, I am facing a problem with the learn by example bit. the tags I am marking as content, are lifted as the contents of the output txt file. But, the data in the following tags are not being fetched.

    Simply, it is not learning by example. So my output file is having only the data that I am marking last as content. Can you tell me why this is happening?

    ReplyDelete
  8. This comment has been removed by the author.

    ReplyDelete
  9. Hi ,
    Can you please show me the example of how to convert COMPLEX XML file to(XML having element inside other element) CSV ? Or if you can give me idea how to process complex XML?

    ReplyDelete
  10. Excellent information with unique content and it is very useful to know about the Informatica.Informatica Training in Bangalore

    ReplyDelete
  11. hi, Serializer is not showing output format as .txt, due to which after running I am getting CM_console error on data processor transformation, kindly let me know if any setting needs to change ?

    ReplyDelete
  12. getting this error: cannot run program "CM_console": CreateProcess error=3, The system cannot find the path specified
    kindly help me resolve this

    ReplyDelete
  13. This doesn't work for complex XML files. Name space doesn't show up

    ReplyDelete