xlate / staedi

StAEDI - Streaming API for EDI: Java library featuring a reader/parser, writer/generator, and validation
Apache License 2.0
127 stars 35 forks source link

An element/composite with minOccurs=0 at impl. schema doesn't override minOccurs=1 from trans. schema #104

Closed benisantos closed 4 years ago

benisantos commented 4 years ago

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.

validation-multi-level-test.zip

MikeEdgar commented 4 years ago

Hi @benisantos - this is somewhat expected behaviour since implementations typically should not override the standard, but rather fall within its guidelines. I think that aligns with the PNRGOV documentation, section 1.4, item 5:

If a composite or data element is defined as conditional in the IATA approved message but must be mandatory to complete a business function, the composite or data element will be indicated with a M for mandatory along with an asterisk (). The `M` will indicate the status differs from the PADIS Message Standard.

The last sentence is the key part, saying that the standard was different from M, i.e. C. I read that as saying that the M* means that the standard is minOccurs="0", but the implementation is minOccurs="1". Is it possible to put the more relaxed rule in the standard and constrain it in the implementation schema?

benisantos commented 4 years ago

Thank you @MikeEdgar for the quick reply. Yes, it's possible to turn the strategy around, and it's like we solved until now :)

Other problem: after upgrade to 1.10.2 I'm getting NPEs in Validator class, line 740:

        // TODO: Implementation nodes must be incremented and validated (#88)
        if (this.isComposite()) {
            this.implComposite = implSeg.getChild(this.composite.getIndex()); // returns null
            this.implElement = this.implComposite.getChild(this.element.getIndex()); // line 740 => NPE
        } else if (this.element != null) {

I have to prepare a failing test case to report. Maybe is it related with TODO #88 ?

MikeEdgar commented 4 years ago

@benisantos - thanks for letting me know about the NPE. Can it be reproduced with the example you gave in the file attached to this issue?

benisantos commented 4 years ago

No, the NPE is thrown in a more complex example, but I'm not authorized to share it :( I'll try to locate the problem and prepare a small test case. Sorry!

MikeEdgar commented 4 years ago

Sure, no problem.

benisantos commented 4 years ago

I've created a new issue (#106) about the NPE with a test case.

MikeEdgar commented 4 years ago

@benisantos - please let me know if anything else is needed with this issue.

benisantos commented 4 years ago

It's ok. Close it when you want. Thank you.

MikeEdgar commented 4 years ago

Thanks @benisantos. Closing this - the solution was to use the less restrictive constraints in the standard. Please re-open in anything else arises with this one.