|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
DFDL Parsing Issue with variable Length Record |
« View previous topic :: View next topic » |
Author |
Message
|
curiousfellow |
Posted: Thu Feb 19, 2015 9:53 am Post subject: DFDL Parsing Issue with variable Length Record |
|
|
Newbie
Joined: 28 Sep 2009 Posts: 1
|
Hi,
I'm facing an issue using DFDL in MB 8.0.0.4
We have a requirement where we receive text file with records separated by EndOfLine character. Some of the records can have varying lengths like 70,80,90 etc and what this length should be is defined in position 10-12 of that record.It can be safely assumed that content of the file is correct and no numeric validation error or anything will happen.
I thought specifying this condition in discriminator for that record type might solve the problem but if I give following expression in discriminator, looks like it can't even evaluate the expression even though that x-path is valid.
{/Records/Transaction/recordType16/rec_length) eq '70'
Looks like only relative path from the current position can be evaluated at that stage. Is that correct or I'm missing something here.
Assuming this is expected bevhaviour in DFDL, do you see any way the file can be parsed as a whole or each individual record needs to be passed separately to a model which will be defined using 'choice' only.
Please point me to any previous discussion regarding this if I've missed that.
Thanks. |
|
Back to top |
|
 |
shanson |
Posted: Mon Feb 23, 2015 2:15 am Post subject: |
|
|
 Partisan
Joined: 17 Oct 2003 Posts: 344 Location: IBM Hursley
|
It sounds like each record has a common prefix and a variable length body? So there are two things you need to solve - the variable length, and the different records. I'd do something like this:
Code: |
el=record
choice
el=record1
el=record2
...
el=recordN
el=record1
sequence
el=type
dfdl:discriminator test="{. eq 1}"
el=length
el=body dfdl:lengthKind="explicit" dfdl:length="{../length}"
sequence
el=field11
el=field12
...
el=field1N
|
The discriminator expression resolves the choice, and the length expression ensures that the correct length is extracted.
If you have a large number of records, and the type is the first thing in the record, then consider treating the type as a dfdl:initiator.
The schemas on the DFDLSchemas GitHub site are good examples to follow. |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|