xlate / staedi Goto Github PK
View Code? Open in Web Editor NEWStAEDI - Streaming API for EDI: Java library featuring a reader/parser, writer/generator, and validation
License: Apache License 2.0
StAEDI - Streaming API for EDI: Java library featuring a reader/parser, writer/generator, and validation
License: Apache License 2.0
Add methods to EDIStreamReader
and EDIStreamWriter
interfaces to retrieve the current standard EDIReference
and the current implementation EDITypeImplementation
instances.
Represented in X12 by the HL
segment. The enhancement should allow loop events generated from HL
loops to be nested according to the parent/child relationship declared by each HL
encountered in the data.
It works with 1.10.1, but fails with 1.10.2. Test case is attached.
Validator
associated with transaction Schema
must be reset before each transaction "loop".
Provide an option to disable validation of the value enumerations defined in a control schema. The option/property will be a boolean
and can be set on an EDIInputFactory
instance using the constant EDIInputFactory.EDI_VALIDATE_CONTROL_CODE_VALUES
. The default value should be true
.
This option/property will allow a user to utilize control schema validation for structural and data type constraints, but still provide support for custom values that may not be defined in the list of enumerated values for an element in the control schema.
Enhance the EDIOutputFactory
and EDIStreamWriter
to use a Schema
(or separate ones for control/message). Throw EDIStreamException
when invalid data is written.
Hi, looking for a way to get the Description of an Element from its Reference Code.
I'm parsing an 837 file and want to know if I can get the element description from the reference code (reader.getReferenceCode())
In other words, is there a way for me to get (as an example) "Organization Name" from "NM103"?
Same question with Loops, how can I get (as an example) "1000B" from "L0001"?
Thanks in advance.
If the empty segment is removed (from schemas and edifact file), the validation works perfectly. Same if the empty segment is moved to second or following positions in the loop.
A failed test is attached.
Create Wiki pages for basic read/write functionality
Support empty segments like the "SRC" one in IATA PADIS EDIFACT (https://www.iata.org/contentassets/18a5fdb2dc144d619a8c10dc1472ae80/pnrgov20edifact20implementation20guide2016_1.pdf).
When an empty segment (SRC') is reached, this exception is thrown:
Message: EDIE003 - Invalid processing state: INVALID (previous: TAG_3); input: '''
We have "fixed" it, but we don't know if it's the best solution :)
The schema syntax
element can only be used currently for segments and composites to indicate relationships between elements. This enhancement will allow for syntax restrictions to be specified at the transaction and loop levels to place constraints on the loops and segments contained therein.
Ignore pretty print output option when segment terminator is newline character
Provide a way to identify and validate implementation-specific loops via specific value(s) in an element using a schema.
Add property to allow resolution of relative schemaLocation
URLs given in schema include
elements.
SchemaFactory.SCHEMA_LOCATION_URL_CONTEXT
Do not write trailing empty components in a composite element or trailing empty elements/composites in a segment.
Reading element BÜTTNER WIDGET COMPANY
from an EDI stream results in the Java String B�TTNER WIDGET COMPANY
.
Writing element BÜTTNER
results in B�TTNER
being written to the output.
In transaction schema, if we put:
<segmentType name="SRC" />
an error occurs parsing the schema: io.xlate.edi.internal.schema.StaEDISchemaReadException: Unexpected XML event [2]
And if we put:
<segmentType name="SRC">
<sequence />
</segmentType>
an event ELEMENT_OCCURRENCE_ERROR
is returned by EDIStreamReader::next
with error type TOO_MANY_DATA_ELEMENTS
.
This issue is related to #10
D7(030,040,050)
If the first item (at position 03) is present, then the items at 04 and 05 cannot be included.
Allow validation errors in writer to be reported without throwing exception
Schema XML parse error with multiple syntax elements
io.xlate.edi.schema.EDISchemaException: EDISchemaException at [row,col]:[618,32]
Message: Unexpected XML event [1]
at io.xlate.edi.internal.schema.StaEDISchemaFactory.createSchema(StaEDISchemaFactory.java:95)
at io.xlate.fresno.schema.boundary.SchemaResource.getTransactionSchema(SchemaResource.java:73)
Support schema inclusion of segment, composite, and element types - without another top-level <interchange>
, <transaction>
, or 'element - using the
` element in v4 schema.
Need to ensure that an invalid state continues to throw EDIException
(subclass of EDIStreamException
) when the Lexer
enters an invalid state.
Add EDIReporter
interface in the style of javax.xml.stream.XMLReporter
to support application error handling outside of the data event stream.
Implement XMLStreamWriter
to write EDI from XML, similar to StaEDIXMLStreamReader
Allow for implementation schemas to be specified in separate files that "extend" from a parent standard schema.
<s:SEG>
<!-- SEG01 missing, treat as empty EDI element in output -->
<e:SEG02>value</e:SEG02>
<!-- SEG03 missing, treat as empty EDI element in output -->
<c:SEG04>
<e:C002-01>value</e:C002-01>
<!-- C002-02 missing, treat as empty EDI component in output -->
<e:C002-03>value</e:C002-03>
</c:SEG04>
</s:SEG>
As of now sender and receiver id in ISA segment is not padded with spaces to make their length to 15 chars.
These padding chars should be added automatically by API rather than the developer using the API to avoid exceptions
X12 TR4 (Clarification Paper)
The ISX segment first appeared in version/release 007040 of the X12 EDI Standard, with ISX01 and ISX02. ISX03 and ISX04 were introduced in version/release 008010. The I11 value in the ISA segment determines the version of the ISX which may be used in the interchange.
The elements features in ISX are listed below. This issue will address the first element.
Add support for EDIFACT interactive interchanges and messages. These are those interchanges identified by the UIH
header segment.
Please comment on this issue if this feature is important to you.
Add support for EDIFACT binary data using the UNO
and UNP
segments.
Please comment on this issue if this feature is important to you.
Regarding question/issue #78, I'm trying implementation schemas to achieve the goal, but I've a problem at "relaxing" the minOccurs attribute of some elements/composites.
A failed test is attached. There is a FIXME comment in the implementation schema about the issue.
Need to -
Allow retrieval of EDI standard name and version from EDIStreamWriter
. Method to match the same retrieval method from EDIStreamReader
.
String getStandard()
If a segment appears out of sequence in a loop and the segment has already appeared earlier in the loop, the elements of the additional occurrence are not reset before validation. This results in element occurrence errors in addition to the (correct) segment occurrence error for the improperly sequenced segment.
Validate implementation constraints on the elements and composites not selected until implementation segment is selected
are there schema files for documents like 850?
Hi,
I am setting up a codeco 96b validation and I noticed you had some predefined files in the library. So I copied your EDIFACT/v3.xml and tried adding a single validation on segment DAM 9500(Type of Damage).
However, I get the message UNEXPECTED_SEGMENT which is pointing me to the DAM segment. I know it has something to do with the grouping of the DAM segment in the interchange XML element, but I just can't find the right way to do it.
Can you please assist?
View codeco 95b:Truugo (DAM is under GRP5>GRP6>C821>7500(Type Of Damage))
My xml is as follows:
codeco95b.zip
Add getTransactionVersion
to EDIStreamReader
, align with existing getVersion
used for the interchange/control version.
EDIFACT release element throws exception from writer when using the UNA
segment.
java.lang.StringIndexOutOfBoundsException: String index out of range: 20
at java.lang.AbstractStringBuilder.charAt(AbstractStringBuilder.java:237)
at java.lang.StringBuilder.charAt(StringBuilder.java:76)
at io.xlate.edi.internal.stream.tokenization.EDIFACTDialect.parseVersion(EDIFACTDialect.java:97)
at io.xlate.edi.internal.stream.tokenization.EDIFACTDialect.initialize(EDIFACTDialect.java:66)
at io.xlate.edi.internal.stream.tokenization.EDIFACTDialect.processServiceStringAdvice(EDIFACTDialect.java:224)
at io.xlate.edi.internal.stream.tokenization.EDIFACTDialect.appendHeader(EDIFACTDialect.java:172)
at io.xlate.edi.internal.stream.StaEDIStreamWriter.write(StaEDIStreamWriter.java:314)
...
PADIS EDIFACT from IATA says (source):
So, our clients are sending files like:
UNA:+.?*'
...
LTS+0/O/SS/NT6604 Y 21FEB 5 LPADSS LK4 1200 1415/NN *1A/E* /NT/ES/C/I/CAB Y//0////'
...
UNZ+1+0001'
Where those asterisks are content, not separators :(
¿Would it be possible to support a setting to ignore the repetition separator?
It would be appreciated if the transaction schema could support something like "wildcard sequences" inside a segmentType
declaration.
The idea is to skip validation of elements/composites of some segments. This can be useful when you are dealing with big "models", and you are only interested in parse and validate part of the "model".
The syntax could be something like:
<segmentType name="FOO">
<sequence>
<any/>
</sequence>
</segmentType>
It's similar to the "any" element in XSD (with processContents="skip"): https://www.w3schools.com/xml/el_any.asp
Thanks in advance
Exception in thread "main" java.lang.IllegalArgumentException: URI is not absolute
at java.net.URI.toURL(Unknown Source)
at io.xlate.edi.internal.schema.SchemaUtils.getXmlSchema(SchemaUtils.java:117)
at io.xlate.edi.internal.schema.SchemaUtils.getControlSchema(SchemaUtils.java:94)
at io.xlate.edi.internal.stream.StaEDIStreamReader.nextEvent(StaEDIStreamReader.java:130)
at io.xlate.edi.internal.stream.StaEDIStreamReader.next(StaEDIStreamReader.java:179)
Currently:
GE01 = 28
GE02 = 97
Correct:
GE01 = 97
GE02 = 28
Describe the bug
Attempting to parse the included EDI, I'm getting the following Exception:
java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 8230
at io.xlate.edi.internal.stream.tokenization.CharacterSet.setClass(CharacterSet.java:193)
at io.xlate.edi.internal.stream.tokenization.X12Dialect.initialize(X12Dialect.java:95)
at io.xlate.edi.internal.stream.tokenization.X12Dialect.appendHeader(X12Dialect.java:167)
at io.xlate.edi.internal.stream.tokenization.Lexer.handleStateHeaderData(Lexer.java:370)
at io.xlate.edi.internal.stream.tokenization.Lexer.parse(Lexer.java:229)
at io.xlate.edi.internal.stream.StaEDIStreamReader.nextEvent(StaEDIStreamReader.java:155)
at io.xlate.edi.internal.stream.StaEDIStreamReader.next(StaEDIStreamReader.java:187)
To Reproduce
EDIInputFactory factory = EDIInputFactory.newFactory();
EDIStreamReader reader = factory.createEDIStreamReader(ediInputStream);
while (reader.hasNext()) {
EDIStreamEvent ediStreamEvent = reader.next();
switch (ediStreamEvent) {
case START_INTERCHANGE:
String[] version = reader.getVersion();
break;
}
}
With the follow as the data used in the ediInputStream
ISA*00* *00* *ZZ*XXXX *ZZ*DDDDDD *200910*1930*U*00400*000075776*0*P*>…
GS*QM*XXXX*DDDDDD*20200910*1930*75776*X*004010…
ST*214*757760001…
B10*0542550913*7727019*XXXX…
L11*900169*PO…
N1*SH*HEATCO INC…
N3*50 HEATCO CT NW…
N4*CARTERSVILLE*GA*30120…
N1*CN*ADDISON HVAC LLC…
N3*7050 OVERLAND RD…
N4*ORLANDO*FL*32810…
N1*BT*TRANSAVER FREIGHT SE…
N3*108 WASHINGTON S…
N4*MANLIUS*NY*13104…
LX*1…
AT7*AG*NS***20200911*1159*ET…
MS2*XXXX*902577*CV…
LX*2…
AT7*AF*NS***20200910*1135*ET…
MS2*XXXX*902577*CV…
AT8*G*L*2085*5…
SE*20*757760001…
GE*1*75776…
IEA*1*000075776…
@MikeEdgar mentioned this might/probably is a bug, "the parser should automatically detect the delimiters, but it's possible there is an issue if it's outside the ASCII range"
Hello,
I would like to know. If let's say I encounter a data error(DATA_ELEMENT_TOO_LONG ), how can I retrieve what the length should be? "A sort of remedy for the error"
Something like:
> case ELEMENT_DATA_ERROR:
> if (reader.getErrorType() != null) {
> /*
> * createSchema.getElementById(reader.getId());
> * to get the schema defined element, so we can access things like
> * "minOccurenc, maxOccurence, minLength etc..."
> *
> * and
> *
> * reader.getRemedyType()
> * so we can show how to fix the error
> */
> ediWriteElement.setError(reader.getErrorType().name());
> }
> break;
Allow SEF files (Standard Exchange Format) to be used as schemas
Hi,
I have had this issue for over a week now and I though to myself, let me consult you guys about it. I have a transaction schema that validates the codeco 95b. Here is a zip file containing the edi file and the transaction file.
edi.zip
What happens is on the TDT segment I get an error TOO_MANY_COMPONENTS staring from element 8178. What I suspect happening is that the error itself act as an component and for that reason the componentIndex cannot be the "componentPosition - 1" but needs to be "componentPosition -2"
I Suspect that for various reasons. The code you sent me earlier in a question I had about errors I also needed to fix the error there as I received outOfBound exceptions. See code below:
"
if (segment == null && transactionSchema != null) {
segment = (EDIComplexType) transactionSchema.getType(location.getSegmentTag());
}
if (segment != null) {
// Obtain an EDIReference for the current element from the segment's list of
// elements
EDIReference reference = segment.getReferences().get(location.getElementPosition() - 1);
ediWriteElement.setReference(reference);
// The element will be either an EDISimpleType (i.e. a simple element) or an
// EDIComplextType (if it is a composite element)
EDIType element = reference.getReferencedType();
if (element instanceof EDIComplexType) {
List<EDIReference> references = ((EDIComplexType) element).getReferences();
try {
EDIReference componentRef = references.get(**location.getComponentPosition() - 2**);
EDISimpleType component = (EDISimpleType) componentRef.getReferencedType();
ediWriteElement.setSimpleType(component);
System.out.println("Not Normal Type");
} catch (IndexOutOfBoundsException e) {
e.printStackTrace();
}
} else {
ediWriteElement.setSimpleType((EDISimpleType) element);
System.out.println("Normal Type");
}
} else {
ediWriteElement.setRemedy("No element type defined for location [" + location + "]");
}
Another platform where I also test my files has no errors on the TDT;
reference:
I hope I have explained this issue very well, let me know If there is anymore information I can provide
I'm not sure if this is a new feature or a question... Our problem is:
One example from PADIS EDIFACT (spec here):
Does the transaction schema support different validation rules depending on the level/loop of the segment?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.