Hi DFDL community,
Below is an xs:choice that is part of my DFDL schema for Windows executable
files. Here is my understanding of implementing choices in DFDL:
An xs:choice consists of a series of sequences.
Daffodil uses dfdl:descrimintor to decide which
sequence to choose.
Is that correct?
Question: When I do this discriminator stuff, I blindly follow the pattern
shown below, i.e., embed dfdl:discriminator within xs:appinfo. When I try to
explain discriminators to people, I just know that they are going to ask: Why?
Why are dfdl:discriminators embedded within xs:appinfo? Discriminators seem to
be handled very different from everything else, why?
How do I respond to these questions? /Roger
<xs:choice>
<xs:sequence>
<xs:annotation>
<xs:appinfo source="http://www.ogf.org/dfdl/">
<dfdl:discriminator
test="{fn:lower-case(xs:string(Hidden_signature)) eq '0b01'}" />
</xs:appinfo>
</xs:annotation>
element declarations for 32-bit executable
</xs:sequence>
<xs:sequence>
<xs:annotation>
<xs:appinfo source="http://www.ogf.org/dfdl/">
<dfdl:discriminator
test="{fn:lower-case(xs:string(Hidden_signature)) eq '0b02'}"/>
</xs:appinfo>
</xs:annotation>
element declarations for 64-bit executable
</xs:sequence>
<xs:sequence>
<xs:annotation>
<xs:appinfo source="http://www.ogf.org/dfdl/">
<dfdl:discriminator
test="{fn:lower-case(xs:string(Hidden_signature)) eq '0701'}"/>
</xs:appinfo>
</xs:annotation>
element declarations for ROM image
</xs:sequence>
</xs:choice>