我正在尝试使用Smooks(1.7)来验证EDIFACT文件。
但是,当文件包含额外的段终止符(')时:
LOC+9+DEANR''
,
它会遇到异常:
Exception in thread "main" org.milyn.SmooksException: Failed to filter source.
at org.milyn.delivery.sax.SmooksSAXFilter.doFilter(SmooksSAXFilter.java:97)
at org.milyn.delivery.sax.SmooksSAXFilter.doFilter(SmooksSAXFilter.java:64)
at org.milyn.Smooks._filter(Smooks.java:526)
at org.milyn.Smooks.filterSource(Smooks.java:482)
at Main.runSmooks(Main.java:96)
at Main.main(Main.java:62)
Caused by: java.lang.IllegalStateException: No current segment available. Possible conditions:
1. A call to moveToNextSegment() was not made, or
2. The last call to moveToNextSegment() returned false.
at org.milyn.edisax.BufferedSegmentReader.assertCurrentSegmentExists(BufferedSegmentReader.java:468)
at org.milyn.edisax.BufferedSegmentReader.getCurrentSegmentFields(BufferedSegmentReader.java:410)
at org.milyn.edisax.unedifact.handlers.UNHHandler$UNTSegmentListener.onSegment(UNHHandler.java:119)
at org.milyn.edisax.BufferedSegmentReader.moveToNextSegment(BufferedSegmentReader.java:378)
at org.milyn.edisax.BufferedSegmentReader.moveToNextSegment(BufferedSegmentReader.java:282)
at org.milyn.edisax.EDIParser.mapSegment(EDIParser.java:565)
at org.milyn.edisax.EDIParser.mapSegments(EDIParser.java:535)
at org.milyn.edisax.EDIParser.mapSegments(EDIParser.java:538)
at org.milyn.edisax.EDIParser.mapSegments(EDIParser.java:453)
at org.milyn.edisax.EDIParser.parse(EDIParser.java:428)
at org.milyn.edisax.EDIParser.parse(EDIParser.java:410)
at org.milyn.edisax.unedifact.handlers.UNHHandler.process(UNHHandler.java:97)
at org.milyn.edisax.unedifact.handlers.UNBHandler.process(UNBHandler.java:75)
at org.milyn.edisax.unedifact.UNEdifactInterchangeParser.parse(UNEdifactInterchangeParser.java:113)
at org.milyn.smooks.edi.unedifact.UNEdifactReader.parse(UNEdifactReader.java:75)
at org.milyn.delivery.sax.SAXParser.parse(SAXParser.java:76)
at org.milyn.delivery.sax.SmooksSAXFilter.doFilter(SmooksSAXFilter.java:86)
... 5 more
我可以知道如何配置Smooks,而不是引发异常,而不是将EDIFACT错误添加到结果中吗?谢谢!!