This sample builds on sample message CSV_2 by including a choice in the repeating, comma separated record. In the input message there is a single header record, followed by a repeating, comma separated record. This repeating record can contain either 2 elements or 7 elements, as defined by the DFDL schema file. The Mapping node modifies the balance field depending on whether the goldmember field is true. Note also that the mapping handles the choice in the customer record. If this mapping is not visible in the map, click the Preferences toolbar button found at the top of the mapping tab, expand the tree in the left, click Message Map Editor, and select Show groups. The output CSV message shows the physical structure of the message that was parsed, transformed in the mapping, and then serialized to the output queue.
This topic includes instructions for running the sample. It also includes an example of an input test message and a corresponding expected output message, so you can confirm that the sample has worked.
For a more detailed explanation of the message model that is used in this sample, see Exploring the Comma Separated Value (CSV) sample.
If you encounter any problems when you run the sample, see Resolving problems when running samples in the WebSphere Message Broker documentation.
You can test the sample input data against the DFDL schema file in the Message Broker Toolkit.
To test the DFDL Schema:
The DFDL Test perspective opens, and the results of your test-parse are displayed in the DFDL Test - Parse view. If the test parse is successful, a message will appear that states, "Parsing completed successfully".
You can view the results of your test-parse in the Logical Instance view. The Logical Instance view displays data in a logical tree view. Use the parser log in the DFDL - Trace view to view any errors that occurred during parsing.
The test message that is used in running this sample is based on the following format:
2011-11-11,X12334,customerdetails<CRLF> Bob,Dyson,true,23,23456,0,1543543.36<CRLF> Jimmy,Pace<CRLF> Ralf,McCartney,false,67,89125,4324307.35,986545.12<CRLF> Elvis,John<CRLF> Rick,Clayton,true,461,33101,1.11,100.01
<CRLF> represents the characters with ASCII hex code points x'0D' and x'0A'.
This sample uses the CSV2CSV message flow. This message flow contains a single MQInput node attached to the queue, CSV2CSV.IN2. The mapping node modifies the balance field depending on whether the goldmember field is true. The output CSV message shows the physical structure of the message that was parsed, transformed, and serialized.
To run the sample:
The message flow parses the CSV message, modifies it accordingly, and serializes back to CSV. The output message is put to the CSV2CSV.OUT1 queue.
For an explanation of this message model, see Exploring the Comma Separated Value (CSV) sample.
The expected output message is:
2011-11-11,X12334,customerdetails Bob,Dyson,true,23,"23,456",0,"1,543,543.36" Jimmy,Pace Ralf,McCartney,false,67,"89,125","4,324,307.5","986,545.12" Elvis,John Rick,Clayton,true,461,"33,101",1.11,100.01