This DFDL schema, CSV_1.xsd, illustrates the simplest model for a comma separated value message. The sample input data, CSV_1.csv, contains a repeating, comma separated record. The sample input data is parsed by using the sample DFDL schema file, a mapping node copies the DFDL domain logical structure tree to an XMLNSC domain tree, and this tree is serialized as an XML message.
This topic includes instructions for running the sample. It also includes sample input data and an expected output message, so you can confirm 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 by using the Message Broker Toolkit.
To test the DFDL schema file:
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:
Bob,Dyson,true,23,23456,0,1543543.36<CRLF><CRLF> represents the characters with ASCII hex code points x'0D' and x'0A'.
Jimmy,Pace,false,1002,10001,-4.32423,654654.99<CRLF>
Ralf,McCartney,false,67,89125,4324307.35,986545.12<CRLF>
Elvis,John,true,3,60699,-0.343242356675,99999999999999.99<CRLF>
Rick,Clayton,true,461,33101,0.000000000000001,100.01
This sample uses the message flow, CSV2XML. This message flow contains a single MQInput node attached to the queue, CSV2XML.IN1. The message flow passes the message through a Mapping node that changes the domain to XMLNSC and puts the message to the queue CSV2XML.OUT1. The output XML message shows the logical structure of the message that was parsed.
To run the sample:
If all the steps are successful, then the sample is complete.
Now look at the DFDL schema file in the Message Broker project, CSVSchemas and the explanation of this message model in Exploring the Comma Separated Value (CSV) sample.
The expected output XML message is:
<io:CSV_1 xmlns:io="http://www.example.org"> <customer> <firstname>Bob</firstname> <lastname>Dyson</lastname> <goldmember>true</goldmember> <housenumber>23</housenumber> <postcode>23456</postcode> <float>0E+0</float> <balance>1543543.36</balance> </customer><customer> <firstname>Jimmy</firstname> <lastname>Pace</lastname> <goldmember>false</goldmember> <housenumber>1002</housenumber> <postcode>10001</postcode> <float>-4.3242301940918E+0</float> <balance>654654.99</balance> </customer> <customer> <firstname>Ralf</firstname> <lastname>McCartney</lastname> <goldmember>false</goldmember> <housenumber>67</housenumber> <postcode>89125</postcode> <float>4.3243075E+6</float> <balance>986545.12</balance> </customer> <customer> <firstname>Elvis</firstname> <lastname>John</lastname> <goldmember>true</goldmember> <housenumber>3</housenumber> <postcode>60699</postcode> <float>-3.43242347240448E-1</float> <balance>99999999999999.99</balance> </customer> <customer> <firstname>Rick</firstname> <lastname>Clayton</lastname> <goldmember>true</goldmember> <housenumber>461</housenumber> <postcode>33101</postcode> <float>1.00000000362749E-15</float> <balance>100.01</balance> </customer> </io:CSV_1>