Variable document structure

+1 vote
asked Feb 14 by emil (130 points)

Hello,

I have a file encoded for AS400(IBM870). File contains x structures, structures can be in file more than one (n), but the order and count is not known. The file always contain at least one structure defined in grammar. 

File content sample Axxxxxxxxxx..........Czzzzz...............Bxxxxxaa.............Aznmopaaas...........Cxxddd...............

File structure example                       Grammar 
--bof--
Record A 
    ID = A
    Value 1 = xxxxx
    Value 2 = xxxxx
    Filler 10
Record C
    ID = C
    Value 1 = zzzzz
    Filler 15
Record B
    ID = B
    Value 1 = xxxxx
    Value 2 = aa
    Filler 13
Record A
    ID = A
    Value 1 = znmop
    Value 2 = aaas
    Filler 11
Record C
    ID = C
    Value 1 = xxddd
    Filler 15
--eof--
  • Records have a fixed length 21
  • ID is always present 
  • Values are different 
  • Record order is unknown 
  • Record repeat is unknown
  • Grammar contains definition for
     record ID (A,B,C,D,E ,F ...)
  • The the file may not contain 
    all the records

 

How to automatically parse a file based on existing grammar definition ?

Please log in or register to answer this question.

...