The VDAReader class is optimized for VDA documents, providing a simple way to parse VDA documents.
The class allows you to parse an incoming EDI document. This class works in two states, loading an entire document at once, or streaming portions of the document. These states are controlled by the BuildDOM property. By default BuildDOM is set to bdEntireDocument which parses the entire document at once, allowing you to use the XPath property to navigate the document.
To save memory for larger documents, you can choose to parse only sections of the document, instead of the entire document. When BuildDOM is set to per interchange (bdInterchange ) or per transaction (bdTransaction), the respective section of the document will be available for use with XPath from within the corresponding Start and End events. Finally, you may choose to set BuildDOM to bdNone, which means no DOM will be built and all data will be available only through events, but also will use very little memory. Below are example steps to parse an entire document:
- First, use LoadSchema to load a schema file into the class. (Only necessary when preserving document structure).
- Open an EDI document or stream by setting input via SetInputStream, InputFile or InputData and calling Parse.
- If BuildDOM is set to bdEntireDocument, the events of the class will fire as the document is parsed, and XPath may be set to access any part of the document.
If bdInterchange or bdTransaction are specified, and Input or ParseFile is called the entire document will be parsed, with only the specified section being saved in memory at any given time. This means if you wish to set XPath to navigate within the section of the document, you will need to do so within the events of the class to prevent further processing of the document while you access the section. When parsing is completely, only the most recently parsed section will be available for use with XPath
If bdNone is specified, then all document information must be obtained through the events fired during parsing.
During parsing, the class performs basic validation of the incoming document. If validation fails, a warning is generated (fired as an event).
The XPath navigation is done through the XPath property. For example:
EDIReader.XPath = "/IX/FG/TX/N1Loop1/N1";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/FG/TX/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/FG/TX/N1Loop1[98='BT']";
To display the structure of the parsed document use DisplaySchemaInfo. This is helpful when deciding how to navigate the document.
The following is the full list of the properties of the class with short descriptions. Click on the links for further details.
|BuildDOM||When True, an internal object model of the EDI document is created.|
|EDIStandardVersion||The version of the EDI specification.|
|ExtraData||Extra data that has not been parsed by the class.|
|InputData||The data to parse.|
|InputFile||The file to parse.|
|Offset||Current offset of the document being parsed.|
|SchemaFormat||The format of the schema file.|
|XChildren||Number of child elements of the current segment.|
|XElements||Collection of elements in the current EDI segment.|
|XPath||Provides a way to point to a specific segment in the document.|
|XSegment||The name of the current segment.|
|XSegmentNumber||The number of the current segment.|
|XSegmentType||Indicates the current segment type.|
|XTag||The tag of the current segment.|
|XTransactionCode||The transaction code of the current segment.|
The following is the full list of the methods of the class with short descriptions. Click on the links for further details.
|CompileSchema||Compiles an existing XSD schema into an optimized binary representation.|
|Config||Sets or retrieves a configuration setting.|
|DisplaySchemaInfo||Returns a string showing the structure of the schema defining the document.|
|DisplayXMLInfo||Returns a string showing the structure of the parsed document as XML.|
|Flush||Flushes the parser and checks its end state.|
|GenerateAck||Generates an EDI acknowledgement.|
|HasXPath||Determines whether a specific element exists in the document.|
|LoadSchema||Loads a schema file describing a Transaction Set.|
|LoadSchemaStream||Loads a schema stream describing a Transaction Set.|
|Parse||Parse the specified input data.|
|Reset||Resets the parser.|
|SetInputStream||Sets the stream from which the class will read the data to parse.|
|TryXPath||Navigates to the specified XPath if it exists.|
The following is the full list of the events fired by the class with short descriptions. Click on the links for further details.
|EndFunctionalGroup||Fires whenever a control segment is read that marks the end of an interchange.|
|EndInterchange||Fires whenever a control segment is read that marks the end of an interchange.|
|EndLoop||Fires when the end of a loop is detected in a transaction set.|
|EndTransaction||Fires whenever a control segment is read that marks the end of a transaction.|
|Error||Information about errors during data delivery.|
|ResolveSchema||Fires whenever a new transaction set is encountered and no schema is found for it.|
|Segment||Fires whenever a data segment in a transaction set is read.|
|StartFunctionalGroup||Fires whenever a control segment is read that marks the start of a functional group.|
|StartInterchange||Fires whenever a control segment is read that marks the start of an interchange.|
|StartLoop||Fires when the starting of a loop is detected in a transaction set.|
|StartTransaction||Fires whenever a control segment is read that marks the start of a transaction.|
|Warning||Fires whenever a validation warning is encountered.|
The following is a list of configuration settings for the class with short descriptions. Click on the links for further details.
|CacheJSONSchemas||Whether to cache JSON schemas.|
|ClearSchemaCache||Clears the cached JSON schemas.|
|ComponentDelimiter||The delimiter separating classes.|
|CrossFieldValidationEnabled||Enables cross-field validation rules.|
|ElementDelimiter||The delimiter character separating data elements.|
|Encoding||The character encoding to be applied when reading and writing data.|
|HasXPath||Determines if the specified XPath exists.|
|ISA11IsRepetitionSeparator||Specifies whether the ISA11 value is treated as a Repetition Separator or Standard Identifier.|
|ReleaseChar||The character used to escape delimiters within values.|
|ResolveXPathOnSet||Determines whether or not the XPath is resolved when set.|
|SegmentDelimiter||The delimiter character separating segments within the EDI document.|
|StrictSchemaValidation||Specifies the behavior during schema validation.|
|BuildInfo||Information about the product's build.|
|GUIAvailable||Tells the class whether or not a message loop is available for processing events.|
|LicenseInfo||Information about the current license.|
|UseDaemonThreads||Whether threads created by the class are daemon threads.|
|UseInternalSecurityAPI||Tells the class whether or not to use the system security libraries or an internal implementation.|