Adding a Preparser

In this section:

How to:

A preparser is designed to convert incoming messages into processable documents. The preparsed document then passes through the standard transformation services to reach the designated processing service. An example of a preparser is a class that accepts an EDI-formatted document and converts it to XML for further processing. For more information on the methodology used in writing preparsers, see the iWay Service Manager Programmer's Guide.

Each preparser uses a class file that must be located in a directory which is in the Java classpath. iWay Service Manager includes preparsers that have been preconfigured.

A Service Manager flow can include multiple preparsers and more than one preparser can handle a document. For example, a document can be processed by preparser A and then, subsequently, by preparser B.

Important: A preparser is run prior to a process flow. Further message processing can be handled in an iWay process flow.


Top of page

x
Procedure: How to Add a Preparser

To add a 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. Select a type of preparser from the list, for example, CICS Preparser (com.ibi.preparsers.CICSPreparser).

    You can also manually type the class name of a preparser that is packaged in a .jar file, which is in the CLASSPATH.

  4. Click Next.

    The configuration parameters pane for the CICS preparser opens.

  5. Provide the required configuration parameters for the preparser, and click Next.

    The Name and Description pane opens.

  6. Provide a name and, optionally, a description, for the preparser, and click Finish.

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

    After a preparser is added to iWay Service Manager, you can assign a preparser to an inlet that is used to construct a channel. For more information, see Configuring Channels.


Top of page

x
Streaming Preparser

To handle large files, iWay Service Manager provides a streaming interface. You can use the streaming preparser 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.

Examples of available streaming preparsers are:



x
Line-Oriented Preparser

iWay Service Manager includes a line-oriented preparser designed to accept an input stream and create smaller input files from the original large file. You can configure the preparser to specify the character that indicates a new record.

The following incoming document can be subdivided into three individual documents, based on the delimiter:

What is your name?
Where do you live?
When were you born?

This document can be divided into three individual documents.

What is your name?
Where do you live?
When were you born?

The preparsers pass the individual documents to the remainder of the flow. The transaction extends for all records in the stream, as per standard iWay Service Manager transaction control. Each record, however, is independent for processing purposes.



x
Procedure: How to Add a Line-Oriented Preparser (Flat Stream PreParser)

To define a line-oriented 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 Flat Stream PreParser {com.ibi.preparsers.XDFlatStreamPreParser}.
  4. Click Next.

    The configuration parameters pane for Flat Stream preparser opens.

  5. In the Delimiters field, type a value that indicates possible delimiters. This parameter is optional.
  6. Click Next.
  7. 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: Flat Stream PreParser

The Flat Stream PreParser splits non-XML messages on a recognized character. The configuration specifies the split character. The default is the end of line for the platform. The character can be specified as any character, a special character, or a hexadecimal character.

A standard use of this preparser is to handle individual lines of a large, delimited file. The following table lists and describes the character representations.

Character Representation

Description

X

Any character

\n

New line

\t

Tab

\r

Carriage return

\xab

Ab are hexadecimal characters such as 0A.



x
Concatenated XML Document Preparser

iWay Service Manager includes a preparser designed to accept input files containing multiple XML documents and create single XML documents from the original input file.

The preparser processes 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 Preparser

To define a concatenated XML document 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.



x
XML Splitter Preparser

iWay Service Manager includes a tag-oriented XML splitter preparser designed to accept an input XML document and create smaller XML files from the original large file. You can configure the preparser to specify the tags or combination of tags to use to split the document.

The preparser supports the last level of the XML splitter preparser as the wildcard, *. This feature causes each entry below the fixed levels to be split off from the input XML document.

The following incoming document with the split parameters of A,B,* can be subdivided into two individual documents.

Incoming Document

Individual Document 1

Individual Document 2

<A>	 
 <B>
        <C1/>
        <C2>
            <D1/>
        </C2>
    </B>
</A>
<A>
    <B>
    </B>
</A>
<A>
    <B>
        <C2>
            <D1/>
        </C2>
    </B>
</A>



x
Procedure: How to Add an XML Splitter Preparser

To add an XML splitter preparser:

  1. In the console, select Registry, and then Preparsers.

    The Preparsers pane opens displaying a list of configured preparsers. You can modify these preparsers or add a new one.

  2. Click Add. The New Preparser Type pane opens.
  3. In the Type field, select XML Split {com.ibi.preparsers.XDXMLSplit}.
  4. Click Next.

    The Configuration Parameters pane opens.

    1. In the Level String field, type the path to the element on which to split. For this example, the path would be entered as:
      /ConfirmBOD
    2. Select True in the Sequence drop-down to set a count attribute in the root.
  5. Click Next.
  6. Provide a name and a description (optional) for the preparser, and click Finish.

    The Preparsers pane opens with your new preparser added to the list.



Example: Adding an XML Splitter Preparser

The following incoming document must be split into two smaller documents:

<?xml version="1.0" encoding="ISO-8859-1"?>
<Root>
      <ConfirmBOD lang="en-US">
            <ApplicationArea>
                  <Sender>
                       <LogicalId>3000</LogicalId>
                  </Sender>
            </ApplicationArea>
            <DataArea>
                  <Confirm>Failure</Confirm>
            </DataArea>
      </ConfirmBOD>
      <ConfirmBOD lang="en-US">
            <ApplicationArea>
                  <Sender>
                       <LogicalId>4000</LogicalId>
                  </Sender>
            </ApplicationArea>
            <DataArea>
                  <Confirm>Success</Confirm>
            </DataArea>
      </ConfirmBOD>
</Root>

The document must be split on the ConfirmBOD tag. The preparser should act on the document and create two documents that look similar to the following:

<Root>
      <ConfirmBOD lang=...>
         ....
      </ConfirmBOD>
</Root>

iWay Software