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>
<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.