Component Fields

Some file formats, like EDI, allow fields to be subdivided into arrays, sub-fields, or composite fields. Collectively, these fields are referred to as component fields in Convert to XML. Typically, the headers of these files contain information about the character used to specify component fields. Convert to XML uses this information to set the default value for the Field Component Separator property and render XML output accordingly.

Consider the following input file, which uses a colon (:) to specify component fields:

Make:Model:Year
               
BMW:R1150RS:2004
               
MZ:Scorpion:1995
               
Ducati:ST2:1997
               

            

Using default values for the Field Element Name ( field) and Component Element Name ( component), Convert to XML creates the following XML output:

<?xml version="1.0" encoding="utf-8"?>
               
<root>
               
	<row>
               
		<component><field>Make</field><field>Model</field><field>Year</field></component>
               
	</row>
               
	<row>
               
		<component><field>BMW</field><field>R1150RS</field><field>2004</field></component>
               
	</row>
               
	<row>
               
		<component><field>MZ</field><field>Scorpion</field><field>1995</field></component>
               
	</row>
               
	<row>
               
		<component><field>Ducati</field><field>ST2</field><field>1997</field></component>
               
	</row>
               
</root>
               

            

Here, the fields Make, Model, and Year are created as sub-fields of the <component> container element.

For line-oriented regions in files containing component fields, you can change the default Field Component Separator property, and the Component Element Name property, that is, the name you want to use for the component fields' container element.

 
Free Stylus Studio XML Training: