Hello DFDL Community,

Within my input is this:

- a series of bytes
- then the string: "This program cannot be run in DOS mode."
- then another series of bytes until arriving at this string: "PE"

I figured that for the first series of bytes I would use xs:hexBinary whose 
length ends when getting to "T" (hex 54)

<xs:element     name="Instructions_in_hex" 
                type="xs:hexBinary" 
                dfdl:lengthKind="pattern" 
                dfdl:lengthPattern="[\x30-\x39\x41-\x46\x61-\x66]+?(?=\x54)" />

The next item is a string of length 39

<xs:element     name="Message" 
                type="xs:string" 
                dfdl:lengthUnits="characters" 
                dfdl:lengthKind="explicit" 
                dfdl:length="39" />

The last item is a series of hex digits whose length ends when getting to 
"P"(hex 50)

<xs:element     name="Instructions_in_hex" 
                type="xs:hexBinary" 
                dfdl:lengthKind="pattern" 
                dfdl:lengthPattern="[\x30-\x39\x41-\x46\x61-\x66]+?(?=\x50)" />

At the bottom of this message is the complete set of declarations.

Unfortunately, it doesn't work. The first <Instructions_in_hex> picks up 
nothing. Then the <Message> element erroneously picks up a bunch of hex digits 
and the first part of the string "This program cannot be run in DOS mode.". 
Then it crashes.

What am I doing wrong, please?  /Roger

<xs:element name="DOS_Stub">
    <xs:complexType>
        <xs:sequence>
            <xs:element         name="Instructions_in_hex" 
                        type="xs:hexBinary" 
                        dfdl:lengthKind="pattern" 
                        
dfdl:lengthPattern="[\x30-\x39\x41-\x46\x61-\x66]+?(?=\x54)" />
            <xs:element         name="Message" 
                        type="xs:string" 
                        dfdl:lengthUnits="characters" 
                        dfdl:lengthKind="explicit" 
                        dfdl:length="39" />
            <xs:element         name="Instructions_in_hex" 
                        type="xs:hexBinary" 
                        dfdl:lengthKind="pattern" 
                        
dfdl:lengthPattern="[\x30-\x39\x41-\x46\x61-\x66]+?(?=\x50)" />
        </xs:sequence>
    </xs:complexType>
</xs:element>

Reply via email to