Non-delimited data in FSD
When there are no delimiters in a data file and the fields are fixed
width, it is considered as being 'truly flat'. In this case the
max-length
attribute on the field element is used to
specify the length of each field.
In fixed length data it is often necessary to pad the data values in
order to guarantee that the fields begin in the correct position. The FSD
handles this using the
trailing-chars
attribute. This attribute defines the
characters that may appear after the actual data and which will automatically
be stripped from the data before it is written to XML. In addition, the FSD
processor uses the
trailing-chars
attribute to determine a suitable filler
character when the data is being converted from XML back to flat format.
Below is an example of an FSD that uses fixed length fields:
<?xml encoding='UTF8' version='1.0' ?> <schema xmlns='http://www.systemsunion.com/2001/TD/SSTransform/fsd/' version='1.0'> <sequence output='no'> <record max-occur='0' name='parent'> <field name='child1' max-length='20' trailing-chars=' '/> <field name='child2' max-length='20' trailing-chars=' '/> </record> </sequence> </schema>
Below is an example of some input data for this FSD:
Child Data 1 Child Data 2 Child Data 3 Child Data 4
and output data for this FSD:
<parent> <child1>Child 1 Data</child1> <child2>Child 2 Data</child2> </parent> <parent> <child1>Child 3 Data</child1> <child2>Child 4 Data</child2> </parent>