The Convert to XML Editor

You use the Convert to XML Editor, shown here, to build a converter. The Convert to XML Editor appears when you create a new converter, or open an existing one (a .conv file).

Figure 150. Convert to XML Editor

The input file is displayed in a document grid; properties that both describe the existing file (encoding and size, for example) and define the XML output that will be generated when converting this file (root and field element names, and whether or not you want the XML to be indented, for example) are displayed in the Properties window. The schema pane shows a representation of the XML Schema that will be output for the converted file.

This section describes the main features of the Convert to XML Editor, including how it interacts with the adapter engine. This section covers the following topics:

Document Grid

The document grid displays the input file's layout, including spaces, field separators, and control characters. The input file's appearance in the document grid is determined, in part, by its format.

This section covers the following topics:

Example - .txt Files

Stylus Studio uses slightly different displays for character-separated and fixed-width .txt files. Consider this file, which uses commas as the field separator:

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

            

Figure 151 shows how this character-separated input file appears in the Convert to XML Editor's document grid. By default, Stylus Studio aligns columns and fills the empty cells of the shorter rows with a light blue to aid readability:

Figure 151. Character-Separated File in the Convert to XML Document Grid

You can remove these spaces from the display and view the file in its native format by clicking the Align Fields button ( ) on the tool bar, or by selecting Convert to XML > Align Fields on the menu. This results in the layout shown in Figure 152.

Figure 152. Character-Separated File without Aligned Fields

Fixed-width files are displayed in a slightly different fashion. Consider this fixed-width input file:

Deep-sea octopus      Bathypolypus arcticus http://www.dal.ca/~ceph/TCP/barctic.html        
               
Blue-ringed octopus   Hapalochlaena lunulatahttp://www.dal.ca/~ceph/TCP/lunulata.html       
               
Caribbean reef octopusOctopus briareus      http://www.dal.ca/~ceph/TCP/obriar.html         
               
Giant octopus         Octopus dofleini      http://www.dal.ca/~ceph/TCP/giant.html          
               
Common octopus        Octopus vulgaris      http://www.dal.ca/~ceph/TCP/Octopusvulgaris.html
               
Red octopus           Octopus rubescens     http://www.dal.ca/~ceph/TCP/redocto.html        
               
Octopus Salutii       Octopus salutii       http://www.dal.ca/~ceph/TCP/Osalutii.html       
               
Octopus Macropus      Octopus macropus      http://www.dal.ca/~ceph/TCP/Omacropus.html 
               

            

In a fixed-width file, the empty cells represent actual values (spaces) in the input file. In the second row of this input file, for example, there are three spaces between the first and second columns:

Figure 153. Fixed-Width File in the Convert to XML Document Grid

Display of Delimiting and Control Characters

Stylus Studio displays delimiting and control characters in a way that distinguishes them from plain text values.

  • Delimiting characters, like the comma used in the example in Figure 151, are displayed with a dark blue background. For files that include sub-fields or arrays (like EDI, for example), the sub-field separator character is shown in a different shade of blue. Sub-sub-fields delimiting characters are shown in a shade of purple.
  • Control characters (line feeds and carriage returns, for example) are shown using their abbreviated ASCII value. A carriage return (0x0D) line feed (0x0A) is shown as , for example. ASCII abbreviations are aligned vertically, to preserve space, as shown in this representation of the ASCII value for tab (0x09): .
  • Stylus Studio understands all Unicode characters,. When editing Line-Oriented Region and Field Name values in the Properties window, you can enter mnemonic values for the C1 and C0 control characters in the following ranges:

    • C0 control characters with a value from >= 0x00 to <= 0x1F
    • C1 control characters with a value from >=0x80 to <= 0x9F
    • For example, you could enter TAB or HT in the Field Separator field in the Properties window, and Stylus Studio would correctly interpret that value. For a list of commonly used control characters, see Specifying Control Characters.

  • Characters that are discarded from output (like line terminators such as CR and LF and comment lines) are displayed against a gray background.

You can hide control characters by clicking the Toggle Control Characters button ( ) on the tool bar, or by selecting ConvertToXML > Toggle Control Characters from the menu.

Field Names

User-defined field names - values that Stylus Studio uses to create the element names in converted XML - are displayed in green, as shown here:

Figure 154. User-defined Field Names are Shown in Green

You can edit these names

  • In-place, by double-clicking the field name in the grid
  • In the Field Element Name field of the Properties window

If the field names are taken from a row within the file itself, Stylus Studio displays a blue arrow in the document grid margin to indicate this.

Figure 155. Blue Arrow Indicates Field Names Taken from the File

See Naming Fields to learn more about naming fields for XML output by Convert to XML converters.

Document Grid Display Features

In addition to aligning fields in character-delimited files, the Convert to XML Editor's document grid has several other features that aid readability.

Ruler

You can display a ruler that identifies each column:

Figure 156. Ruler Helps Identify Columns

To display the ruler, click the Toggle Ruler button ( ) on the tool bar, or select ConvertToXML > Toggle Ruler from the menu.

Displaying Pattern Matches

You can define match patterns using regular expressions to control which rows are converted to XML and, optionally, the name to use for these rows. You can highlight rows that match the patterns that you have defined, as shown here:

Figure 157. Matching Rows Are Displayed in Yellow

To highlight matching rows, click the Highlight Matching Rows button ( ) on the tool bar, or select ConvertToXML > Highlight Matching Rows from the menu.

Matching rows are displayed in a light yellow, with a green check in the grid's margin. A red X identifies rows that do not match the pattern. Gray squares identify rows that match a pattern other than the pattern defined for the row that currently has focus. See Specifying Multiple Match Patterns for more information on this feature.

Tip

 

Only rows that match the same pattern that the current row matches are highlighted. Also, tooltips appear when you hover the pointer over the match symbols. These tooltips display the pattern that the row matches.

See Pattern Matching to learn more about using regular expressions to define match patterns.

Grid Lines

The document grid displays both vertical and horizontal grid lines by default; you can hide/show them independently. In the example shown in Figure 158, horizontal grid lines are hidden from the display:

Figure 158. You Can Hide Horizontal and Vertical Grid Lines

To hide horizontal and vertical grid lines, click the Toggle Horizontal Grid Lines ( ) and/or Toggle Vertical Grid Lines ( ) buttons on the tool bar, or select ConvertToXML > Toggle Horizontal Grid Lines and/or Toggle Vertical Grid Lines from the menu.

Tip

 

Hiding horizontal lines while displaying the ruler is an effective way to quickly scan columns.

Fonts

By default, the input document is displayed using the Courier New font in 12pt. You can change the display font to suit your personal preference using the Edit > Change Font and Edit > Font Size menus.

Moving Around the Grid

You can move the cursor around the grid

  • Using the Space bar on your keyboard
  • Using the directional arrows and Page Up, Page Down, Home, and End keys on your keyboard
  • Using your mouse (click on the character on which you want to place the cursor
  • Using the Go To dialog box

Figure 159. Use the Go To Dialog Box to Navigate the Document Grid

Using Go To

You use the Go To dialog box to jump to a specific location in the file you are using to create your converter. You can use it to move the cursor to a specific

  • Position in the file
  • Region
  • Position or row within a region
  • Column within the current row

When you first display the Go To dialog box, values in the Go To fields reflect the cursor's current location within the file. The values in the Maximum fields display the maximum values for each category (file size, number of regions, and so on) for the portion of the file read into the Convert to XML Editor by Stylus Studio.

To display the Go To dialog box, select Edit > Go To from the menu.

Properties Window

The Properties window, like the one shown in Figure 160, displays information about the input file, as well as settings that Stylus Studio will use convert files to XML.

Figure 160. Properties Window for a .txt File

Information in the Properties window includes

  • Information read or inferred from the input file when it is first opened in the Convert to XML Editor. Examples include the file name, file size, and number of characters that were read. Some values, such as the type of encoding, can be edited. Informational fields that cannot be edited are identified with a blue circle: .
  • Values you want the Convert to XML converter to use when converting this input file and other files of this type to XML. Output properties include the root element name, the namespace and namespace prefix, and the field element name. These fields are identified with a green arrow over a document icon: .

How Properties are Organized

Properties displayed in the Properties window are organized in the following categories:

  • Input File - read-only information read or inferred from the input file, and editable properties that affect XML output. These properties affect the file as a whole when it is converted to XML. Input file properties are identified by this icon: .
  • XML Output URL - properties that affect the XML document created by the Convert to XML converter, including the name you want to use for the root element, and whether or not you want to indent the XML. Output URL properties are identified by this icon: .
  • Region Type - read only information inferred from the input file, and editable properties that affect XML output. Examples include line terminating and escape characters. These properties affect a contiguous portion of the file (that is, a given line-oriented or fixed-width region) when it is converted to XML. Region properties are identified by this icon: .
  • Row Element Name - properties that affect which rows of the input file are output to XML and how they are output, including the name you want to use for the row. Row properties are identified with this icon: .
  • Field Element Name - read-only information read or inferred from the input file, and editable properties that affect XML output. These properties affect only fields in a given region of the file when it is converted to XML. Field properties are identified by this icon: .

Note

 

Informational properties, that is, properties that do not affect XML output, are displayed with the following icon: . These properties are displayed when you click the Toggle Informational Properties button.

Properties for Fixed-Width and Line-Oriented Input Files

Fixed-width and line-oriented input files have different properties - line-oriented properties include the line terminator and field separator characters, and fixed-width files have a row length, for example. See Properties Reference to learn more about individual properties.

Schema Pane

The schema pane displays a representation of the XML Schema for the XML document that will be output when the input file is converted to XML.

Figure 161. Schema Pane Shows Output Schema Representation

You can double-click on a row element to display the Set Row Name and Match Pattern dialog box, shown in Figure 162. This functionality provides an alternative to editing the row name and specifying a match pattern in the Properties window.

Figure 162. Set Row Name and Match Pattern Dialog Box

See Rows to learn more about specifying conversion properties for rows.

 
Free Stylus Studio XML Training: