Converting the Region Type

The Region Type field in the Properties window displays information about the type of region Stylus Studio inferred when the file was first read. Its value is either Fixed-width, Line-oriented, or No-output.

Tip

 

Information about No-output regions is not displayed in the Properties window.

Stylus Studio's Convert to XML interprets regions with CR/LF control characters as line-oriented regions. There might be occasions, however, when you want to change the region type from line-oriented to fixed-width, or vice versa. This section describes the tools you can use to change a region from one type to another.

Consider the following file fixed-width file:

Make        Model    Year    Mileage
               
BMW         R1150RS  2004    14274  
               
Kawasaki    GPz1100  1996    60234  
               
Ducati      ST2      1997    24000  
               
MotoGuzzi   LeMans   2001    12393  
               
BMW         R1150R   2002    17439  
               
Ducati      Monster  2000    15682  
               
Aprilia     Futura   2001    17320 
               

            

It is a simple .txt file with fields ( Make, Model, and so on) that have been created using spaces. Each new row was created using the Enter key in the text editor, resulting in CR/LF control characters at the end of each line that cause Convert to XML to interpret the file as a single line-oriented region, like this:

Figure 175. Fields are Aligned by Default

For display purposes, we can remove the spaces Stylus Studio has inserted for readability (the cells with the light blue shading) by clicking the Align Fields ( ) button. This results in a display that resembles the source ( Figure 176), but Stylus Studio still considers the region to be line-oriented.

Figure 176. Turning Off Align Fields Can Aid Readability

When you convert a line-oriented region to a fixed-width region, Convert to XML removes spaces it added for readability and depicts only the spaces in the original input file used to create the fields and the field values themselves, as show in Figure 177.

Figure 177. Line-Oriented Regions Converted to Fixed-Width

By default, Stylus Studio displays fixed-width files using an 80-character row. This accounts for the input files appearance when it is first displayed as a fixed-width file - if you scan the document, you can see that all of the file's original information, including the CR/LF control characters has been retained, but that the formatting differs - the original input file had eight rows; now it has four rows of 80 characters.

Tip

 

You can adjust the width of fixed-width regions. See Adjusting Fixed-Width Regions.

How to Convert a Region Type

To convert a region type:
1. Place the cursor anywhere in the region you want to change.
2. Click the Convert to Fixed-Width Region ( ) or Convert to Line-Oriented Region ( ) button. These actions are also accessible from the ConvertToXML menu and the shortcut menu in the Convert to XML Editor.
3. If you have converted a line-oriented region to a fixed-width region, adjust the row length as needed. See Adjusting Fixed-Width Regions.
 
Free Stylus Studio XML Training:
W3C Member