|
Home > Online Product Documentation > Table of Contents > Controlling XML Output Controlling XML OutputConvert to XML provides several ways for you to control the XML output created by the Convert to XML converter. Most XML output is specified using properties displayed in the Properties window. Some XML output, such as the number of regions or the number of fields in a row, are specified using the Convert to XML Editor. This section describes the properties used to control some of the most common output operations. See Properties Reference for detailed information on all properties. This section covers the following topics: Specifying Element NamesYou can specify names for the following in an XML document output by the converter:
Specifying FormatThere are several ways to exercise control over the format of the XML document output by the converter.
Omitting Regions and Fields, and RowsStylus Studio allows you to omit specific regions and fields from an input file when it is converted to XML.
Pattern MatchingYou can use regular expressions to specify match patterns for the rows in the input file. Only those rows in the input file that match the pattern you specify are output to XML when the file is converted. The simplest way to define a match pattern is to use the Match Pattern property in the Row Element Name section of the Properties window. ExampleConsider the following input file:
If you specify a simple regular expression, say,
Note that the match pattern also appears as a new node in the schema pane. This new node, the only one defined for this converter at this point, uses the default row element name (
Since the match pattern selects only those rows that begin with the letter B, the converter creates the following XML document when it is run against the input file:
See Working with Nodes to learn about adding the row element name/match pattern pairs that define them. Sample Regular ExpressionsThe following table identifies some commonly used regular expressions.
To learn more about regular expression syntax, visit http://www.boost.org/libs/regex/doc/syntax.html . Specifying Multiple Match Patterns
You can specify multiple match patterns for a single file. If we define a new match pattern,
When you define multiple match patterns, the document grid displays a gray square alongside rows that match a pattern other than the one, if any, associated with the currently selected row. In
Figure 177, for example, row 3 is the currently selected row; it matches the pattern
Working with NodesIn addition to defining nodes using the Match Pattern field of the Properties window, you can also use the Set Row Name and Match Pattern dialog box, shown here:
This dialog box allows you to
When you open the dialog box, the Row Element Name and Match Pattern fields contain default values that reflect the currently selected row in the document grid or node in the schema pane. Defining a New NodeTo define a new node:
1. Select a row in the document grid or a node in the schema pane.
2. Select
ConvertToXML > Add Node and Pattern from the Stylus Studio menu.
Alternative: Select Add Node and Pattern from the document grid or schema pane shortcut menu. The Set Node and Pattern dialog box appears.
3. Change the default values in the
Row Element Name and
Match Pattern fields.
4. Click
OK.
Cloning a NodeTo clone a node:
1. Select the node in the schema pane that you want to clone.
Alternative: Select the row in the document grid that is represented by a row element name/match pattern pair you want to clone.
2. Select
ConvertToXML > Clone Node and Pattern from the Stylus Studio menu.
Alternative: Select Clone Node and Pattern from the document grid or schema pane shortcut menu. The Set Node and Pattern dialog box appears.
3. Change the default values in the
Row Element Name and
Match Pattern fields as needed.
4. Click
OK.
Editing a NodeTo edit a node:
1. Select the node in the schema pane that you want to edit.
Alternative: Select the row in the document grid that is represented by a row element name/match pattern pair you want to edit.
2. Select
ConvertToXML > Edit Node and Pattern from the Stylus Studio menu.
Alternative: Select Edit Node and Pattern from the document grid or schema pane shortcut menu. Alternative: Double-click the node. The Set Node and Pattern dialog box appears.
3. Change the default values in the
Row Element Name and
Match Pattern fields as needed.
4. Click
OK.
Removing a NodeWhen you remove a node, you are deleting the row element name/match pattern pair from the converter you are defining. To remove a node:
1. Select the node in the schema pane that you want to remove.
Alternative: Select the row in the document grid that is represented by a row element name/match pattern pair you want to remove.
2. Select
ConvertToXML > Remove Node and Pattern from the Stylus Studio menu.
Alternative: Select Remove Node and Pattern from the document grid or schema pane shortcut menu. Alternative: Press the Delete key. A warning message appears.
3. Click
Yes to remove the node, otherwise click
No.
Using Lookup Lists
You can define lookup lists for individual fields. When Stylus Studio converts the input file, it replaces the string in the input file (the lookup) with the value you have defined for it in the
Lookup List dialog box.
Figure 179 shows an example of a lookup list that has been defined for a
For any
Input file values that do not match a lookup are emitted in the XML document as-is, allowing exceptional values to be decoded. For example, you might have a temperature lookup list with these values for a
All other temperatures would be emitted as-is. Defining Lookup Lists
Lookups are case-sensitive, so, for example, a lookup of
You can define lookup lists only for fields in rows for which a match pattern (even a blank match pattern, as is the default) exists. Finally, you can paste comma- and tab-delimited text directly into the lookup list. This allows you to easily reuse existing lookup tables without having to re-enter text. To define a lookup list:
1. Select a row for which a match pattern exists.
2. Click the
Lookup List entry field in the
Properties window.
The Lookup List dialog box appears.
3. Enter lookup/value pairs in the corresponding entry fields.
4. When you are done, click
OK.
Working with Lookup ListsThe following table summarizes the functions of the Lookup List dialog box, which allow you to work with new and existing lookup lists.
Using Key=Value CharactersThe Key=Value Character Region property allows you to set the separator for key=value pairs as seen in the input file. When Stylus Studio converts an input file to XML, it uses the value on the left side of the key=value character for the element name, and the value on the right for the element value. Consider the following input file:
If you set the Key=Value Character property to =, Stylus Studio creates the following XML document when you preview the converter:
|

Cart


