|
1 | 1 | * [Programmability of Omniparser](#programmability-of-omniparser)
|
2 |
| - * [Out\-of\-Box Basic Use Case](#out-of-box-basic-use-case) |
3 |
| - * [Add A New custom\_func](#add-a-new-custom_func) |
4 |
| - * [Add A New custom\_parse](#add-a-new-custom_parse) |
5 |
| - * [Add A New File Format](#add-a-new-file-format) |
6 |
| - * [Add A New Schema Handler](#add-a-new-schema-handler) |
7 |
| - * [Put All Together](#put-all-together) |
8 |
| - * [In Non\-Golang Environment](#in-non-golang-environment) |
| 2 | + * [Out\-of\-Box Basic Use Case](#out-of-box-basic-use-case) |
| 3 | + * [Add A New custom\_func](#add-a-new-custom_func) |
| 4 | + * [Add A New custom\_parse](#add-a-new-custom_parse) |
| 5 | + * [Add A New File Format](#add-a-new-file-format) |
| 6 | + * [Add A New Schema Handler](#add-a-new-schema-handler) |
| 7 | + * [Put All Together](#put-all-together) |
| 8 | + * [In Non\-Golang Environment](#in-non-golang-environment) |
9 | 9 | * [Programmability of Some Components without Omniparser](#programmability-of-some-components-without-omniparser)
|
10 |
| - * [Functions](#functions) |
11 |
| - * [IDR](#idr) |
12 |
| - * [CSV Reader](#csv-reader) |
13 |
| - * [Fixed\-Length Reader](#fixed-length-reader) |
14 |
| - * [EDI Reader](#edi-reader) |
15 |
| - * [JSON Reader](#json-reader) |
16 |
| - * [XML Reader](#xml-reader) |
| 10 | + * [Functions](#functions) |
| 11 | + * [IDR](#idr) |
| 12 | + * [CSV Reader](#csv-reader) |
| 13 | + * [Fixed\-Length Reader](#fixed-length-reader) |
| 14 | + * [Full EDI Reader](#full-edi-reader) |
| 15 | + * [Non\-Validating EDI Segment Reader](#non-validating-edi-segment-reader) |
| 16 | + * [JSON Reader](#json-reader) |
| 17 | + * [XML Reader](#xml-reader) |
17 | 18 |
|
18 | 19 | # Programmability of Omniparser
|
19 | 20 |
|
@@ -237,15 +238,42 @@ reader that does
|
237 | 238 | For more reader specific settings/configurations, check
|
238 | 239 | [Fixed-Length in Depth](./fixedlength_in_depth.md) page.
|
239 | 240 |
|
240 |
| -## EDI Reader |
| 241 | +## Full EDI Reader |
241 | 242 |
|
242 | 243 | Use [`NewReader()`](../extensions/omniv21/fileformat/edi/reader.go) to create an EDI reader that does
|
243 | 244 | - segment min/max validation
|
244 | 245 | - XPath based data row filtering
|
245 | 246 | - Context-aware error message
|
246 | 247 |
|
247 |
| -Future TO-DO: create a version of non-validating EDI reader for users who are only interested in |
248 |
| -getting the raw segment data, without any validation. |
| 248 | +For more reader specific settings/configurations, check |
| 249 | +[EDI in Depth](./edi_in_depth.md) page. |
| 250 | +
|
| 251 | +## Non-Validating EDI Segment Reader |
| 252 | +
|
| 253 | +Use [`NewNonValidatingReader()`](../extensions/omniv21/fileformat/edi/reader2.go) to create a |
| 254 | +non-validating EDI segment reader. Sometimes user might not want the full EDI reader that does |
| 255 | +many packing/unpacking and structural/hierarchical validations, they simply need an EDI segment |
| 256 | +reader that reads out all the raw segments and their elements/components. |
| 257 | +
|
| 258 | +Usage example: |
| 259 | +``` |
| 260 | +r := edi.NewNonValidatingReader( |
| 261 | + strings.NewReader("....."), |
| 262 | + &edi.FileDecl{ |
| 263 | + SegDelim: ..., |
| 264 | + ElemDelim: ..., |
| 265 | + ..., |
| 266 | + // No need to set SegDecls. Just all the needed top level edi.FileDecl settings. |
| 267 | + }) |
| 268 | +for { |
| 269 | + seg, err := r.Read() |
| 270 | + if err == io.EOF { |
| 271 | + break |
| 272 | + } |
| 273 | + if err != nil { ... } |
| 274 | + // seg contains the raw segment data, and is of edi.RawSeg type. |
| 275 | +} |
| 276 | +``` |
249 | 277 |
|
250 | 278 | ## JSON Reader
|
251 | 279 | See [IDR](#idr) notes about the JSON/XML readers above.
|
|
0 commit comments