Skip to Content
0
Former Member
Jan 24, 2011 at 10:21 AM

Optional Fields with StrictXml2PlainBean

45 Views

Hi,

I am trying to use StrictXml2PlainBean to convert a simple XML document to a fixed length file but because there are optional fields in the XML if these fields are not passed to the StrictXml2PlainBean then if fails.

For example, I have a simple XML document that has 3 fields:

<XML>

<Name 0...n>

<Phone 0...n>

<Address 0...n>

</XML>

in the config for the StrictXml2PlainBean I have the fixed length config set as:

dataRec.fieldLengths 10, 6, 10

the outputted file should look like:

NAME PHONE ADDRESS

NAME PHONE ADDRESS

(spaces inserted to fill the fixed length)

some documents don't all have Phone Numbers and this is causing the Bean to fail because it thinks the ADDRESS field is the second field and then fails. I was hoping that if a field is not present then it will fill that fields location with spaces. So the file would look like this:

NAME PHONE ADDRESS

NAME ADDRESS

Is this possible to do?

Thanks