Streaming Preparsers

In this section:

To handle large files, iWay Service Manager provides a streaming interface. You can use streaming preparsers only with the HTTP, File, and JMS adapters. To use a streaming preparser in conjunction with other preparsers, you must define it as the first preparser in the chain. The following streaming preparsers are available:


Top of page

x
Concatenated XML Document Stream Preparser (com.ibi.preparsers.XDXMLStreamPreParser)

Syntax:

com.ibi.preparsers.XDXMLStreamPreParser

The Concatenated XML Document Stream preparser accepts input files containing multiple XML documents and creates single XML documents from the original input file.

For example, this preparser can process the following batch of XML documents:

<?xml version="1.0" encoding="UTF-8"?>
<hi>This is my document</hi>
<hi>This is my document</hi>
<hi>This is my document</hi>
<hi>This is my document</hi>


x
Procedure: How to Add a Concatenated XML Document Stream Preparser

To define a Concatenated XML Document Stream preparser:

  1. In the left console pane of the Registry menu, select Preparsers.

    The Preparsers pane opens.

  2. Click Add. The Preparser Type pane opens.
  3. In the Type field, select XML Stream PreParser {com.ibi.preparsers.XDXMLStreamPreParser} and click Next.
  4. Provide a name and a description (optional) for the preparser, and click Finish.

    The preparser is added to the list in the Preparsers pane.



x
Reference: XML Stream Preparser

The incoming XML document is divided into smaller documents, broken at a specified repeating child, for example:

<a>
<b>
<c>one</c>
<b>
<b>
<c>two</c>
</b>
</a>

With a split specified as a/b, it results in three passes through the configured flow.

Pass 1

<a>
<b>
<c>one</c>
</b>
</a>

Pass 2

<a>
<b>
<c>two</c>
</b>
</a>

Pass 3

No data.


Top of page

x
Delimited Value Stream Preparser (com.ibi.preparsers.XDDelValStream)

Syntax:

com.ibi.preparsers.XDDelValStream

Description:

The Delimited Value Stream preparser is a delimited value handler, which is useful when the incoming message consists of a delimited value stream such as lines of comma separated values. The first line can optionally hold field names (DIF format input). An XML document is generated from the input with a child node of each row, and children of that row in turn for each value.

In a use case scenario, the Delimited Value Stream preparser can be used when an incoming message consists of a batch of flat files that are delimited by a special character, such as '|'. This message also needs to be converted to XML format.

Parameters:

Parameter

Description

Root name *

The element name of the outer tag.

Dif *

Determines whether the first line should be treated as an element name.

Delimiter *

Determines the delimiter to be used. Select comma or tab from the drop-down list, or enter a specific character in the field.

Rows

The number of rows in each document.

Trim values

Determines whether all values should be trimmed.

Header

Determines whether the first line shouuld be ignored.

Quotes

Determines whether surrounding quotes should be eliminated.

Empty elements

Determines whether empty elements at the 'right' should be eliminated.

Example:

  1. Select the Del Val Stream (com.ibi.preparsers.XDDelValStream) preparser from the Type drop-down list and click Next.

    The configuration parameters pane opens.

  2. Enter testroot in the Root name field.
  3. Select false from the Dif field drop-down list.
  4. Enter | in the Delimiter field and leave the default values selected for all the remaining fields.
  5. Click Next.

    The name and description pane opens.

  6. Enter a name (for example, DelvalStreamPreparser) and an optional description.
  7. Click Finish.
  8. Construct an inlet, for example, PreparseInlet, which is associated with a file listener and the new preparser (DelvalStreamPreparser).
  9. Define a simple move route and a default outlet for the channel.
  10. Build, deploy, and start the channel.
  11. Create a simple input text document (for example, TestData.txt), which contains the following:
    02|penny|copper|$0.01
    03|one dollar|paper|$1.00
    04|five dollars|paper|$5.00
    05|ten dollars|paper|$10.00
    06|twenty dollars|paper|$20.00

    When this input document is processed by the channel, an output XML document is generated with the following contents:

    <?xml version="1.0" encoding="ISO-8859-1" ?><testroot RowCount="4"><row rowcnt="1"><_nb02>03</_nb02><penny>one dollar</penny><copper>paper</copper><_dlr0.01>$1.00</_dlr0.01></row><row rowcnt="2"><_nb02>04</_nb02><penny>five dollars</penny><copper>paper</copper><_dlr0.01>$5.00</_dlr0.01></row><row rowcnt="3"><_nb02>05</_nb02><penny>ten dollars</penny><copper>paper</copper><_dlr0.01>$10.00</_dlr0.01></row><row rowcnt="4"><_nb02>06</_nb02><penny>twenty dollars</penny><copper>paper</copper><_dlr0.01>$20.00</_dlr0.01></row></testroot>


x
Flat Stream Preparser (com.ibi.preparsers.XDFlatStreamPreParser)

Syntax:

com.ibi.preparsers.XDFlatStreamPreParser

Description:

The Flat Stream preparser is used to split non-XML messages based on a recognized character. During configuration, the character can be specified as any character, a special character, or a HEX character.

The Flat Stream preparser is useful when handling individual lines of a large, delimited file.

Parameters:

Parameter

Description

Delimiters

List of possible delimiters (default is new line). Possible values include:

  • X - Any character.
  • \n - New line.
  • \r - Carriage return.
  • \t - Tab.
  • \xab - ab are HEX characters, such as 0A.

Example:

  1. Select the Flat Stream (com.ibi.preparsers.XDFlatStreamPreParser) preparser from the Type drop-down list and click Next.

    The configuration parameters pane opens.

  2. Enter \r as a value for the Delimiters parameter and click Next.

    The name and description pane opens.

  3. Enter a name (for example, FlatStreamPreparser) and an optional description.
  4. Click Finish.
  5. Construct an inlet, for example, PreparseInlet, which is associated with a file listener, the new preparser (FlatStreamPreparser), and an En Tag preparser to enclose each split flat file into an XML file.
  6. Define a simple move route and a default outlet for the channel.
  7. Build, deploy, and start the channel.
  8. Create a simple input text document (for example, document2.txt), which contains the following:
    First Line
    Second Line
    Third Line
    Fourth Line

    When this input document is processed by the channel, the output document (document2_1.txt) contains the following:

    <?xml version="1.0" encoding="ISO-8859-1" ?><testroot>First Line</testroot>

    The output document (document2_2.txt) contains the following:

    <?xml version="1.0" encoding="ISO-8859-1" ?><testroot>Second Line</testroot>

    The remaining output follows the same format.


iWay Software