You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@daffodil.apache.org by "Costello, Roger L." <co...@mitre.org> on 2018/11/11 21:15:29 UTC

How to implement in DFDL an input that has a sequence of flags?

Hello DFDL Community,

My input file contains (among other things) a 2-byte (16-bit) sequence of flags. Here are the 2-bytes for one input file (in hex):

	01 07

Which corresponds to this binary: 

	0000 0001 0000 0111

Each bit with a value of 1 corresponds to a characteristic (flag):

bit 1 means: Relocation information was stripped from file
bit 2 means: The file is executable
...
bit 16 means: The bytes of the word are reversed

The bytes are in little endian order, so bit #1 is the rightmost bit, right?

I think that for the above example I would like to generate the following XML. In the above binary there are 4 one's, so I have correspondingly 4 <characteristic> elements.

<characteristics>
    <characteristic>Relocation information was stripped from file</characteristic>
    <characteristic>The file is executable</characteristic>
    <characteristic>COFF line numbers were stripped from file</characteristic>
    <characteristic>The computer supports 32-bit words</characteristic>
</characteristics>

Is that a good way to represent the characteristics (flags)?

I have no idea how to implement this in DFDL. Would you help please?

/Roger