-
-
Notifications
You must be signed in to change notification settings - Fork 36
Reading EDI Data (Configuration)
This article assumes the reader has basic knowledge of EDI structures and terminology
The EDIStreamReader
can be configured using several properties (set on the EDIInputFactory
) to modify the reader's behavior.
// Create an EDIInputFactory
EDIInputFactory factory = EDIInputFactory.newFactory();
factory.setProperty(EDIInputFactory.EDI_VALIDATE_CONTROL_CODE_VALUES, false);
// Obtain an InputStream of the EDI document to read.
InputStream stream = new FileInputStream(...);
// Create an EDIStreamReader from the stream using the factory
EDIStreamReader reader = factory.createEDIStreamReader(stream);
// Continue processing with the reader...
EDI_VALIDATE_CONTROL_STRUCTURE
EDI_VALIDATE_CONTROL_CODE_VALUES
XML_DECLARE_TRANSACTION_XMLNS
EDI_IGNORE_EXTRANEOUS_CHARACTERS
JSON_NULL_EMPTY_ELEMENTS
JSON_OBJECT_ELEMENTS
XML_USE_SEGMENT_IMPLEMENTATION_CODES
Out of the box, instances of EDIStreamReader
will validate the control structures of X12 and EDIFACT messages (interchange, group, and transaction headers and trailers).
If you wish to disable the validation of control the structure, including field sizes and types, set the EDIInputFactory.EDI_VALIDATE_CONTROL_STRUCTURE
property to false
on an instance of EDIInputFactory
prior to creating a new EDIStreamReader
.
Out of the box, instances of EDIStreamReader
will validate the control structures of X12 and EDIFACT messages (interchange, group, and transaction headers and trailers). This validation includes checking that some fields contain one of an enumerated list of values (e.g. a known transaction set code in X12 segment ST, element 1).
If you wish to disable the validation of the code values but keep the validation of the structure, including field sizes and types, set the EDIInputFactory.EDI_VALIDATE_CONTROL_CODE_VALUES
property to false
on an instance of EDIInputFactory
prior to creating a new EDIStreamReader
, as shown below.
When using the XMLStreamReader
produced by StAEDI's EDIInputFactory
, this property will generate the StAEDI XML namespace attributes on the TRANSACTION
element.
The namespaces are declared in the EDINamespaces
class. This behavior may be desirable when reading EDI-as-XML and you wish to split the resulting XML data into separate
files, one per transaction, and still keep track of the XML namespaces.
Since: 1.13
Default: false
When set to true, non-graphical, control characters will be ignored in the EDI input stream when not used as delimiters. This includes characters ranging from 0x00 through 0x1F and 0x7F.
Since: 1.14
Default: false
When set to true, simple data elements not containing data will be represented via the JSON parsers as a null
value.
Since: 1.14
Default: false
When set to true, simple data elements will be represented via the JSON parsers as JSON objects. When false, simple elements will be JSON primitive values (string, number) in the data array of their containing structures.
Since: 1.21
Default: false
When set to true, the XML elements representing segments in an EDI implementation schema will be named according to the schema-defined code
attribute for the segment.
By default, StAEDI will read EDI input using the UTF-8 standard character set. The character set may be overridden by creating an instance of EDIStreamReader
(via EDIInputFactory
) with the name of an alternate Charset
. Names of Charset
s that return true
for a call to Charset#isSupported
may be used.