Component and Sub-Component Fields

Some file formats - many EDI variants, for example - 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 semi-colon (;) to specify component fields:

Make;Model;Year;Color;Seat
               
BMW;R1150RS;2004;grey,metallic;black,vinyl
               
MZ;Scorpion;1995;green,clearcoat;black,vinyl
               
Ducati;ST2;1997;red,clearcoat;black,leather
               

            

Using the first row to supply the field names and default Component Element Name ( component), the Convert to XML creates the following XML output (first two elements shown for brevity):

<?xml version="1.0" encoding="utf-8"?>
               
<root>
               
	<row>
               
		<Make>BMW</Make>
               
		<Model>R1150RS</Model>
               
		<Year>2004</Year>
               
		<Color>
               
			<component>grey</component>
               
			<component>metallic</component>
               
		</Color>
               
		<Seat>
               
			<component>black</component>
               
			<component>vinyl</component>
               
		</Seat>
               
	</row>
               
	<row>
               
		<Make>MZ</Make>
               
		<Model>Scorpion</Model>
               
		<Year>1995</Year>
               
		<Color>
               
			<component>green</component>
               
			<component>clearcoat</component>
               
		</Color>
               
		<Seat>
               
			<component>black</component>
               
			<component>vinyl</component>
               
		</Seat>
               
	</row>
               
...
               

            

The <component> elements are created as subelements of the <Color> and <Seat> elements.

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

Translating X12 Documents to XML

The X12 to XML Converter is a built-in function of the adapter library. The XML that is generated is well commented and indented, and can be used anywhere XML is normally used — with XML Schemas, XSLT, XQuery, etc.

SQL/XML Tutorial

Many developers need to be able to write applications that work for databases from multiple vendors. This SQL/XML Tutorial refers to SQL/XML, XQuery, and Native XML Programming Languages to do just that.

Sun Multi-Schema XML Validator (MSV)

Learn how to integrate the Multi Schema Validator (MSV) into Stylus Studio as one of the Custom Validation Engines. It will work for files with a DTD, a single XSD, or both a DTD and a single XSD.

Advertising & Marketing

Learn about top advertising and marketing companies that are leveraging Stylus Studio 2006 to enhance their everyday work experience.

Stylus Most Wanted

 
Free Stylus Studio XML Training:
W3C Member