Group Example

This example shows a Flat File Schema that parses a repeating set of records using groups. Each set of the repeating record contains records of different types as shown in the following example input Flat File data:

Figure 1. An example input Flat File

In this example data, the first, second, and third records of the repeating set are each a different type of record. In addition, this example shows how types stored in the Type Library tab are used in a Flat Files Schema. In this example, you view and test an existing Flat File Schema rather than creating the Flat File Schema from scratch.

To open, view, and test the Flat File Schema used to parse the input data displayed in Figure 1:

Procedure

  1. In this example, the Flat File Schema is already built in the FlatFileSchemasExample project. To view the Flat File Schema, you must first extract the FlatFileSchemasExample project:
    1. Find the Default Create Path defined in Studio - the directory that new projects are created in. To view the current Default Create Path, select File > Preferences... from the Studio toolbar menu. The Preferences dialog opens. The current Default Create Path shows at the bottom of the pane. By default, the Default Create Path is located in the following directory:

      C:\Documents and Settings\myLogin\My Documents

      Where myLogin represents your Windows login name.

    2. Find the FlatFileSchemasExample.zip file that contains the files that make up the FlatFileSchemasExample project. If you accepted the defaults during the installation of Studio, this file is located in the following directory:

      C:\Program Files\IBM\WebSphere Cast Iron Studio 3.X\Samples\FlatFileSchema

    3. Copy the FlatFileSchemasExample.zip file from the FlatFileSchema directory to the Default Create Path directory.
    4. Extract the contents of FlatFileSchemasExample.zip file into the Default Create Path directory.
  2. Open the FlatFileSchemasExample project:
    1. Select File > Open Project... from the Studio toolbar menu. The Open dialog box shows.
    2. Browse for and open the FlatFileSchemasExample directory.
    3. Click the FlatFileSchemasExample.sp3 file and click Open. The project is displayed.
  3. Open the prebuilt vegPO Flat File Schema. In the Flat File Schemas folder of the Project tab, double-click the vegPO Flat File Schema. The nodes of the vegPO Flat File Schema are displayed in the Schema Layout tab and the properties of the vegPO root node show in the right pane.
  4. Test the vegPO Flat File Schema:
    1. In the test pane, click Browse. The Open Sample Test Data File dialog box opens.
    2. Browse for the vegPO.txt file that contains the input data.  If you accepted the defaults during the installation of Studio, this file is located in the following directory:

      C:\Program Files\IBM\WebSphere Cast Iron Studio 3.X\Samples\FlatFileSchema

    3. Click Open. The input data from the vegPO.txt file shows in the left pane of the Test tab.
    4. Click the Test (Test icon ) icon. In the results pane (located on the right side of the test pane), the result of the conversion is displayed as XML data.
  5. In the Schema Layout tab, click the vegPO root node. The vegPO root node is displayed with the following properties:
    1. Structure property is equal to Delimited - The structure of the root node is delimited.
    2. Child delimiter is equal to Line End- The child records are delimited by an end-of-line.
    3. Child Delimiter Position is equal to After - Expect the delimiters after each record
    4. Repeat delimiter is equal to Line End- Repeating records are also delimited by end-of-line.
  6. In the Schema Layout tab, click the orderingStore node. The first line of the input data is highlighted within the test pane as shown in the following figure:
    VegPO header figure

    The first record of the vegPO Flat File Schema is a header record called orderingStore that occurs only once. In the Schema Layout tab, the fields and record that make up the orderingStore record display as children. This first line is parsed into the fields and records that make up the orderingStore record.

    After the first header record, the sets of repeating elements start. Each set of repeating elements contains three child records of different types as shown in the following figure:

    VegPO showing a set of repeating elements containing three child records of different types.

    A repeating record that contains child records of different types can be modeled in the Flat File Schema Editor using groups. Groups are only required when the data does not provide any additional delimiters or structure to clearly mark the beginning and end of repetitions that contain more than one record. The delimiters for the repetitions are inherited from the parent record or root node. In this example for the vegPO root node, the repeat delimiter is set to end-of-line. The orders group node uses end-of-line delimiter to parse its repeating records

  7. In the Schema Layout tab, click the orders group node. Note the following graphical changes in the panes:
    • In the left subpane of the test pane, all the lines after the header line are highlighted. This highlighting indicates that after parsing, all the data after the first record are all assigned to the orders group node.
    • In the Basic Properties pane, the Occurrences of the orders group is Unbounded. This setting means that there can be one or more instances of this group.
    • In the Basic Properties pane, for the orders group the Type is equal to order. This setting means that the orders group is based on the order group type. The contents and the properties of the order group type are defined in the Type Library tab.
  8. Select the Type Library tab. The record types and group types used in the vegPO Flat File Schema display. The order group type contains three records as shown in the following figure:
    vegPO order group

    The following icon represents a record that is based on a record type:

    Record based on type icon.

    The orders group with the order group type define a set of repeating records of different records because of the following characteristics:

    • There can be one to many instances of the orders group.
    • The order group type contains three records of different types.
    • The orders group is based on or inherits from the order group type.
    The repeating relationship between the orders group and the order group type is shown in the following figure:
    vegPO repeat pattern
  9. In the Type Library tab, click the id record node of the order group type. Note the following graphical changes in the panes:
    • In the Basic Properties pane, the Type of the id record is equal to the record type named orderID. This setting means that the id record is based on the orderID record type.
    • In the left subpane of the test pane, the first line of each repeating record is highlighted as shown in the following figure:
      VegPO test ID
      This highlighting indicates that the first line of each repeating record is assigned to the id record.
  10. In the Type Library tab, click the shipdate record node of the order group type. Note the following graphical changes in the panes:
    • In the Basic Properties pane, the Type of the shipdate record is equal to the record type named shippingDate. This setting means that the shipdate record is based on the shippingDate record type.
    • In the Basic Properties pane, the Structure of the shipdate record is Positional. This setting means that the child fields of the shipDate record are determined by their position and length in the record and not by delimiters.
    • In the left subpane of the test pane, the second line of each repeating record is highlighted as shown in the following figure:
      Figure indicates that the second line of each record (the shipDate line) is highlighted.
      This highlighting indicates that the second line of each repeating record is assigned to the shipDate record. The shipDate record contains three positional child fields (month, day, and year) that are inherited from the shippingDate record type.
  11. In the Type Library, click the month field node of the shippingDate record type. In the left subpane of the test pane, the values assigned to the month field are highlighted as shown in the following figure:
  12. In the Type Library, click the contents record node of the order group type. Note the following graphical changes in the panes:
    • In the Basic Properties pane, the Type of the contents record is equal to the record type named orderContent. This setting means that the contents record is based on the orderContent record type.
    • In the left subpane of the test pane, the third line of each repeating record is highlighted as shown in the following figure:
      The figure shows that the third line of the repeating record (showing the vegetable name and weight in pounds) is highlighted.
      The orderContent record type contains the vegetables record. The vegetables record its contains a set of repeating vegetable records. The vegetable record contains a name field and a pounds field.
  13. In the Type Library, click the name record node of the orderContent record type. In the left subpane of the test pane, the values assigned to the name field are highlighted as shown in the following figure:
    This figure shows that the values assigned to the name field are highlighted.