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

Ignore repetition separator #77

Closed benisantos closed 4 years ago

benisantos commented 4 years ago

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?

MikeEdgar commented 4 years ago

Hi @benisantos - is there any way your clients can disable the repetition separator in the UNA? by sending a space? The trouble is that the documentation says it is not used, but then tells you to send a value in UNA :-)

benisantos commented 4 years ago

No, I'm afraid not. There are several clients acting like that, and there is a legacy app supporting those things... :(

MikeEdgar commented 4 years ago

@benisantos - I can add the ability to force the value of a delimiter, i.e. setting the repetition character to a blank space in this case would work. Until that is ready, do you have any way to change that position of the UNA to a blank space prior to parsing it?

benisantos commented 4 years ago

Perfect @MikeEdgar ! In the meantime, we will preprocess the file to "hack" the UNA segment :)

Thank you so much.

MikeEdgar commented 4 years ago

@benisantos - my plan for implementing this change is to only allow the repetition separator to be used if the EDIFACT version is 4 or later (UNB element 1, component 2). This means if you write a UNA segment directly or by overriding the delimiters when writing with the EDIStreamWriter, it will result in a blank written in the UNA for the repetition character. This is the documented use for the UNA prior to EDIFACT version 4. Given that the repetition character is supposed to be ignored for PADIS, this should not be an issue.

Please let me know if you see any issues with that approach.

MikeEdgar commented 4 years ago

@benisantos - I also now noticed that although the documentation states the repeater is not used and does not need to be escaped, the first example shown in the document shows the repeater being escaped...

The existing unit test that used that example was updated for this change: https://github.com/xlate/staedi/pull/81/files#diff-4699360291fcb4eb52a263e42c556afc

benisantos commented 4 years ago

I've tried version 1.9.5-SNAPSHOT from master and it works as expected! Thank you so much @MikeEdgar

MikeEdgar commented 4 years ago

@benisantos - version 1.10.0 has been released with this change included.

benisantos commented 4 years ago

Thank you again @MikeEdgar