Hello DFDL community,
If my input file is this:
MZ
Then I want the output XML to be this:
<input>
<Magic-Number>MZ</Magic-Number>
<Executable>Windows executable</Executable>
</input>
If my input file is this:
PNG
Then I want the output XML to be this:
<input>
<Magic-Number>PNG</Magic-Number>
<Image>PNG image</Image>
</input>
If my input file is this:
PK
Then I want the output XML to be this:
<input>
<Magic-Number>PK</Magic-Number>
<Archive>Zip archive</Archive>
</input>
If the input is none of those, then I want the output XML to be this:
<input>
<Magic-Number>...</Magic-Number>
<Unrecognized>Unrecognized magic number</Unrecognized>
</input>
Below is my DFDL schema. It produces this error:
element reference {}Executable cannot have the dfdl:inputValueCalc property.
Why am I getting that error? /Roger
<xs:element name="input">
<xs:complexType>
<xs:sequence>
<xs:element name="Magic-Number" type="xs:string" />
<xs:choice>
<xs:choice dfdl:choiceDispatchKey="{./Magic-Number}">
<xs:element ref="Executable" dfdl:choiceBranchKey="MZ" />
<xs:element ref="Image" dfdl:choiceBranchKey="PNG" />
<xs:element ref="Archive" dfdl:choiceBranchKey="PK" />
</xs:choice>
</xs:choice>
<xs:element name="Unrecognized" type="xs:string"
dfdl:inputValueCalc="{'Unrecognized magic number'}" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Executable" type="xs:string" dfdl:inputValueCalc="{'Windows
executable'}" />
<xs:element name="Image" type="xs:string" dfdl:inputValueCalc="{'PNG image'}" />
<xs:element name="Archive" type="xs:string" dfdl:inputValueCalc="{'Zip
archive'}" />