Pages

Solution : Delimited Flat File Schema Misssing Fields At End

Friday, September 30, 2011
Q:
I have a Flat File Schema with records delimited by CRLF and fields delimited by a pipe symbol (|).  Occasionally we receive a record with some of the fields on the end of one record missing.  The file is not being processed correctly.  Since those fields are optional, I would like to be able to accept both type of file.
For example, a normal record might look like this:
TAG1|A1|B1|C1|D1
TAG2|A2|B2|C2|D2|E2|F2
TAG3|A3|B3|C3
But sometimes we get one like this (note that D2, E2, and F2 are missing):
TAG1|A1|B1|C1|D1
TAG2|A2|B2|C2
TAG3|A3|B3|C3
Is there any way that we can accommodate this requirement? I would like for both files to be processed.  The resulting xml should just have empty nodes for the missing fields.
Any help will be appreciated.

Sol:


Use the choice group node in your schema to achieve this. Create a choice group with option for fileds "C2|D2|E2|F2" and for "C2" only. Get more details about choice group from:
or
1) Set the "Allow Early Termination" property on the "schema" node of your flat file schema to "Yes".
2) Then set the "Min Occurs" property on all the fields which are optional to "0".
3) Validate your instance and have fun.

Regards

2 comments:

  1. Thanks - That was awesome.

    ReplyDelete
  2. the second solution didn't work for me. I haven't tried the first one yet

    ReplyDelete

Post Your Comment...