Beruflich Dokumente
Kultur Dokumente
Serializer Overview
In the preceding exercises, you have defined parsers, which convert documents in various formats to
XML. In this exercise, you will create a serializer that works in the opposite direction, converting XML
to another format.
Usually, it is easier to define a serializer than a parser because the input is a fully structured,
unambiguous XML document.
The serializer that you will define is very simple. It contains only four serialization anchors, which are
the opposite of the anchors that you use in parsing. Nonetheless, the serializer has some interesting
points:
The serializer is recursive. That is, it calls itself repetitively to serialize the nested sections of an
XML document.
The output of the serializer is a worksheet that you can open in Excel.
You will define the serializer by editing the IntelliScript. It is also possible to generate a serializer
automatically by inverting the operation of a parser. For more information about defining serializers,
see the Data Transformation Studio User Guide.
Prerequisite
The output of this exercise is a *.csv (comma separated values) file. You can view the output in
Notepad, but for the most meaningful display, you need Microsoft Excel.
You do not need Excel to run the serializer. It is recommended only to view the output.
Requirements Analysis
The input XML document is in Exercise folder.
The document is an XML representation of a family tree. Notice the recursive structure. Each Person
element can contain a Children element, which contains additional Person elements.
<Person>
<Name>Jake Dubrey</Name>
<Age>84</Age>
<Children>
<Person>
<Name>Mitchell Dubrey</Name>
<Age>52</Age>
</Person>
<Person>
<Name>Pamela Dubrey McAllister</Name>
<Age>50</Age>
<Children>
<Person>
<Name>Arnold McAllister</Name>
<Age>26</Age>
</Person>
</Children>
</Person>
</Children>
</Person>
Output the names and ages of the Person elements as a *.csv file, which has the following structure:
Jake Dubrey,84
Mitchell Dubrey,52
Pamela Dubrey McAllister,50
Arnold McAllister,26
Project Properties
The properties window displays many useful options, such as the input and output encoding that are
used in your documents and the XML validation options. For more information the project properties,
see the Data Transformation Studio User Guide.
Points to Remember
A serializer is the opposite of a parser: it converts XML to other formats. You can design a serializer
that outputs to any data format, for example, Microsoft Excel.
You can create a serializer either by generating it from an existing parser or by editing the IntelliScript.
A serializer contains serialization anchors that are analogous to the anchors that you use in a parser,
but work in the opposite direction.
In an IntelliScript editor, you can hide or display the panes by choosing the commands on the
IntelliScript menu or on the toolbar.
We recommend that you store all files associated with a project in the project folder, located in your
Eclipse workspace. You can determine the folder location by clicking File > Properties or Project >
Properties.
A single project can contain multiple transformation components such as parsers, serializers, and
mappers. The startup component can call secondary serializers, parsers, or mappers, which are
defined in the same project. Secondary components can process portions of a document. Recursion,
a component calling itself, is supported.