WTX Fundamentals Training LAB 6 Mapping Fixed Length Data to

advertisement
WTX Fundamentals Training
LAB 6
Mapping Fixed Length Data to XML
In this lab we’ll be using the following materials:
WTX Version(s):
Text Files:
Type Tree:
v8.3.0.4
bank_data.txt
fixed_length_flat_file.mtt, XML_Data.mtt
Description:
In order to build a map in WTX from scratch we need to determine our inputs and
outputs. For this lab we will be using a flat file for the input and an XML file for our
output in the map.
We have already built the trees in previous labs, so use these as well as the sample
bank input file named bank_data.txt for building the WTX map.
© 2012 Copyright DeBruin Consulting. Do not reproduce. Not for distribution.
1
Steps
1.
We begin by right clicking on the Map Files folder in our WTX_Demo project and
selecting New > Map Source:
© 2012 Copyright DeBruin Consulting. Do not reproduce. Not for distribution.
2
2.
Select the WTX_Demo project as the location of the new map:
3.
A “help” window will appear telling us the next step. Select OK:
© 2012 Copyright DeBruin Consulting. Do not reproduce. Not for distribution.
3
4.
Click the New Map icon as shown below:
5.
A window will appear asking for a name for you map. Use Bank_to_XML:
© 2012 Copyright DeBruin Consulting. Do not reproduce. Not for distribution.
4
6.
We can see the map name in the Outline View below in the Map Navigator in the lower
left corner of the WTX perspective. You’ll notice that the map is blue in color. When we
add inputs and outputs the map will turn purple telling us this is a top level, executable
map. An executable map represents the physical file that can be put on a server.
7.
The next step is to create an input type tree for our map. Right click on the Input Tree as
shown below and select New:
© 2012 Copyright DeBruin Consulting. Do not reproduce. Not for distribution.
5
8.
The window below will appear and giving the properties for the input card which
represents the source file and structure. The CardName, TypeTree, Type, and FilePath
will all need to be populated. Give the card the name Bank_Data:
9.
Select the fixed_length_flat_file.mtt Type Tree:
10.
Select the FILE Record Copybook Type:
© 2012 Copyright DeBruin Consulting. Do not reproduce. Not for distribution.
6
11.
Select your input file using the bank_data.txt as your input:
© 2012 Copyright DeBruin Consulting. Do not reproduce. Not for distribution.
7
12.
Your Input Card should appear as follows:
13.
Next we need to create an output card to represent our XML output. In order to do this
we can right click on Output Card and select New:
© 2012 Copyright DeBruin Consulting. Do not reproduce. Not for distribution.
8
14.
The Output Card dialog will be displayed. We will need to populate four fields in this
window: CardName, TypeTree, Type, and FilePath. Use the name XML for the
CardName, select the XML_Data.mtt Type Tree, Select the Doc > XSD Type, and
populate the FilePath with an output filename of bank_data_output.xml:
15.
Your map should appear as follows:
© 2012 Copyright DeBruin Consulting. Do not reproduce. Not for distribution.
9
16.
In order to map the input data to the output XML we’ll need to create mapping rules. To
do this we can drag and drop from the input card to the output card. Expand the file
element until you see the account_record as shown below:
17.
We want to map the RECORD Group to the account_record so we’ll drag and drop the
input object to the output side:
Notice the RECORD Group can be seen in the Rule to the right of account_record, but it
can also be seen on the Rule Bar near the top of the screen. The Rule Bar is where
we’ll make all of our changes to the rules such as adding functions.
© 2012 Copyright DeBruin Consulting. Do not reproduce. Not for distribution.
10
18.
Since the RECORD Group and the account_record both occur multiple times we’ll need
to use a functional map. A Functional Map, in this case, is similar to a while loop and
allows us to trigger an output object to be built as many times as the input occurs.
Create the functional map by first using this rule below:
=f_Each_Record( RECORD Group:Bank_Data )
19.
Next we’ll use the Functional Map Wizard to create the functional map. Click on the icon
below to create this:
20.
The window below appears:
21.
We have three green “smiley faces” which means WTX recognizes these objects and we
can proceed to Create the functional map. NOTE: A yellow icon signifies unknown object
and a red icon signifies an invalid object was used.
Click create and the Close to complete the functional map wizard.
© 2012 Copyright DeBruin Consulting. Do not reproduce. Not for distribution.
11
22.
We are taken to the newly created functional map as shown below:
23.
Expand ACCOUNT on the input side and account on the output side. We see that we’re
able to drag & drop the ACCOUNT_NBR to account_nbr and BANK_ID to bank_id as
shown below:
© 2012 Copyright DeBruin Consulting. Do not reproduce. Not for distribution.
12
24.
We can drag TRANSACTION to transaction as well, but notice that they have the (s)
following them? This mean we’ll need to build another functional map at the transaction
level in order to trigger the output data to be built. Use the functional map shown below:
=f_Each_Transaction( TRANSACTION:In1 )
The functional map wizard appears and we can Click create and Close:
25.
Drag the Items from the input side to the output side as shown below:
26.
Switch to Composition View by using the tab in the lower left hand corner. The nesting of
the maps can be seen here showing which maps call each other verses the Outline View
which shows the maps in alphabetical order:
© 2012 Copyright DeBruin Consulting. Do not reproduce. Not for distribution.
13
27.
We notice that at the top level, executable map name Bank_to_XML we have some
empty Rule Cells. WTX needs to have a rule in every output cell in order to build. IF you
build a map and see several errors it may be due to several empty rule cells. To fix this
we need to use the rule =NONE.
To auto populate several empty rule cells we can use Rules > Insert NONE if Empty:
28.
XML requires that we use the version of “1.0” in XML files. To do this we can delete the
NONE rule in the Prolog, expand the Prolog, use the rule =”1.0” in the version element,
and set the remain in rules to NONE as shown below:
© 2012 Copyright DeBruin Consulting. Do not reproduce. Not for distribution.
14
29.
All of our rule cells have rules, so we can build the map to check for errors. Our map
built successfully, but if you’d like to see the build results you can look in the Organizer
located in the Outline View under the Executable Map:
30.
When we build and run the map we should have the result below:
© 2012 Copyright DeBruin Consulting. Do not reproduce. Not for distribution.
15
Download