Defining and Joining Regions

An input file can contain any number of regions; fixed-width and line-oriented can exist in the same file. The Convert to XML Editor provides tools that allow you to define new regions and join existing ones.

This section covers the following topics:

Defining a Region

When you define a region in an input file, Stylus Studio splits the region at the current cursor location. The new region starts with the character on which the cursor resided when the region was defined, but it can be of either type - fixed-width or line-oriented - regardless of the type of the original region.

Consider the following input file:

# Bike Inventory Overview 2004-10-01 09:00:07EDT
               
European
               
Make      Model    Year    Mileage
               
BMW       R1150RS  2004    14274
               
Ducati    ST2      1997    24000
               
MotoGuzzi LeMans   2001    12393
               
BMW       R1150R   2002    17439
               
Ducati    Monster  2000    15682
               
Aprilia   Futura   2001    17320
               
 
               
Japanese
               
Make      Model    Year    Mileage
               
Kawasaki  GPz1100  1996    60234
               
Honda     VFR      1999    52375
               
Yamaha    YZF600r  1997    42310
               

            

By default, Stylus Studio reads this as a file with a single region. You might decide you want your XML to distinguish headers from actual records and treat the two accordingly (not generating headers as XML, for example).

When you define a new region, the Convert to XML Editor renumbers all the rows, using a region:row number format. In addition, different colors are used to help distinguish one region's rows from the next, as shown in Figure 155.

Figure 155. Regions Are Numbered and Colored Differently

Field and row values are independent across regions. For example, the <row> element might be <reg1>, <reg2>, and so on for each of the regions in an input file.

To define a region:
1. Place the cursor in the document grid on the character with which you want to start the new region.
2. Click the Start New Line-Oriented Region Here ( ) or Start New Fixed-Width Region Here ( ) button. These actions are also accessible from the ConvertToXML menu and the shortcut menu in the Convert to XML Editor.

Stylus Studio defines the new region and renumbers existing regions accordingly.

Joining Regions

You can join regions that you define as well as regions that Stylus Studio interpreted when it first read the input file. You can join the current region to either adjacent region - the previous region, or the next region.

The region type after the join operation depends on whether you are joining with the previous region or the next region.The region you are joining assumes the type of the region to which it is being joined.

Region Joined With
Resulting Region Type
Next
The region you are using to perform the join
Previous
The region to which you are joining
Table 16. Region Type After Joining Regions

To join a region:
1. Place the cursor anywhere in the region you want to join with another region.
2. Click the Join with Previous Region ( ) or Join with Next Region ( ) button. These actions are also accessible from the ConvertToXML menu and the shortcut menu in the Convert to XML Editor.

Stylus Studio joins the region you specified in step 1with the adjacent region.

 
Free Stylus Studio XML Training: