IPWorks EDI 2020 Python Edition

Questions / Feedback?

parse Method

Parse the specified input data.

Syntax

def parse() -> None: ...

Remarks

This method parsed the input data specified by input_file or input_data.

During parsing the following events may fire:

After on_parse returns the document may be traversed by setting the x_path property. The XPath navigation is done through the x_path property. For example:

EDIReader.XPath = "/IX[1]/FG[1]/TX[2]/N1Loop1[1]/N1[1]";
This example path means the following: Select the first N1 segment within the first iteration of the N1Loop1, within second transaction in the first functional group and interchange.

You can also make use of XPath conditional statements to locate the first element which matches a name=value. For example, you could use the following XPath to locate the path of the first element within any N1Loop1 that has a name=N101 and value=BT:

EDIReader.XPath = "IX[1]/FG[1]/TX[1]/N1Loop1[N101='BT']";

Note that the conditional statements will search the children, but not the grand children of the element on which the conditional statement is applied. For instance in the above example the children of N1Loop1 will be searched, but the grandchildren will not.

Additionally if the schema loaded is a ArcESB JSON schema the element Id (from the schema) can be used in the conditional statement. For instance instead of N101 the following is also acceptable:

EDIReader.XPath = "IX[1]/FG[1]/TX[1]/N1Loop1[98='BT']";

Input Properties

The class will determine the source of the input based on which properties are set.

The order in which the input properties are checked is as follows:

When a valid source is found the search stops.

InputData Notes

When setting data to parse via input_data fragments or complete documents may be specified. To parse data in chunks set input_data and call on_parse for each fragment.

When the parser is finally reset via the reset method, all buffered text is flushed out through the extra_data property.

Since the class can be used to parse EDI data fragments, the internal buffer will not be cleared until reset is called. If you plan to use this method to parse multiple complete EDI documents be sure to call reset between calls.

Copyright (c) 2022 /n software inc. - All rights reserved.
IPWorks EDI 2020 Python Edition - Version 20.0 [Build 8203]