Copyright © Cloud Software Group, Inc. All Rights Reserved
Copyright © Cloud Software Group, Inc. All Rights Reserved


Chapter 11 Parse Palette : Parse Data

Parse Data
Activity
The Parse Data activity takes a text string or input from a file and processes it, turning it into a schema tree based on the specified Data Format shared configuration.
You can use any mechanism to obtain or create a text string for processing. For example, you can use the Read File activity to obtain text from a file, or you can retrieve a text field from an adapter message. You can also specify a text file to read using this activity.
You might use this activity in a number of situations. For example, you may have a file that consists of multiple lines of comma-separated values (as in data obtained from a spreadsheet). You may also want to insert that data into a database table. To do this, read and parse the file into a data schema with the Parse Data activity. Then use a JDBC Update activity to insert the data schema into a database table.
Configuration
The Configuration tab has the following fields.
The Data Format shared configuration to use when parsing the text input. See Data Format for more information.
Input can either be a text string or a file. If the input is a text string, supply the string to the textString input item. If the input is a file, supply the file name and location to the fileName input item.
Input
See TIBCO ActiveMatrix BusinessWorks Process Design for more information about mapping and transforming input data.
The input for the activity is the following.
Output
The output for the activity is the following.
The schema specified by the Data Format resource is contained in this output item.
During parsing, if any of the Required data items are missing, the records are displayed in the Error Row. If there are missing Optional items, the records are displayed in the Output Row.
true if no more records are available for parsing. false if there are more records available.
Example
The example contains two input records containing five data items, ID, FName, LName, Address and Age. All the items are declared mandatory.
,FN1,LN1,Pune,99
2,FN2,LN2,Pune,33
Shown below is the output of the two records, after parsing them.
As the field "ID" is missing from the first record, the entire record appears in the ErrorRows element.
 
<?xml version = "1.0" encoding = "UTF-8"?>
<Output>
      <Rows>
           <root>
                <ID>2</ID>
                <FName>FN2</FName>
                <LName>LN2</LName>
                <Address>Pune</Address>
                <Age>33</Age>
           </root>
       </Rows>
      <ErrorRows>
           <ErrorString>,FN1,LN1,Pune,99</ErrorString>
      </ErrorRows>
      <EOF>true</EOF>
</Output>
 
When the ID field is declared Optional, and is missing, it is not an error. The records appear in the output string :
 
<?xml version = "1.0" encoding = "UTF-8"?>
<Output>
      <Rows>
          <root>
               <FName>FN1</FName>
               <LName>LN1</LName>
               <Address>Pune</Address>
               <Age>99</Age>
          </root>
          <root>
               <ID>2</ID>
               <FName>FN2</FName>
               <LName>LN2</LName>
               <Address>Pune</Address>
               <Age>33</Age>
         </root>
   </Rows>
   <ErrorRows/>
   <EOF>true</EOF>
</Output>
Error Output
The Error Output tab lists the possible exceptions that can be thrown by this activity. See TIBCO ActiveMatrix BusinessWorks Error Codes for more information about error codes and corrective action to take.
Parsing a Large Number of Records
The input for this activity is placed in a process variable and takes up memory as it is being processed. If you are reading a large number of records from a file, the process may consume significant machine resources. To avoid using too much memory, you may want to read the input in parts, parsing and processing a small set of records before moving on to the next set.
To process a large number of records, follow this procedure:
1.
2.
3.
Select the Parse Data activity and click the group icon on the tool bar to create a group containing the Parse Data activity. See TIBCO ActiveMatrix BusinessWorks Process Design for more information about working with groups.
4.
5.
The loop should exit when the EOF output item for the Parse Data activity is set to true. For example, the condition for the loop could be set to the following: string($ParseData/Output/done) = string(true())
6.
Set the noOfRecords input item for the Parse Data activity to the number of records you want to process for each execution of the loop.
7.
You can optionally check the Manually Specify Start Record field to specify the startRecord on the Input tab. If you do this, you must create an XPath expression to properly specify the starting record to read with each iteration of the loop. For example, the count of records in the input starts at zero, so the startRecord input item could be set to the current value of the loop index minus one. For example, $i - 1.
The procedure above is a general guideline for creating a loop group for parsing a large set of input records in parts. You may want to modify the procedure to include additional processing of the records, or you may want to change the XPath expressions to suit your business process.

Copyright © Cloud Software Group, Inc. All Rights Reserved
Copyright © Cloud Software Group, Inc. All Rights Reserved