Hi Mike,

But, but, but, ...

Even when I make the elements local (not global), I get the same error message. 
Here's the local version of the DFDL schema:

<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 name="Executable" type="xs:string"
                                    dfdl:choiceBranchKey="MZ"
                                    dfdl:inputValueCalc="{'Windows 
executable'}" />
                    <xs:element name="Image" type="xs:string"
                                    dfdl:choiceBranchKey="PNG"
                                    dfdl:inputValueCalc="{'PNG image'}" />
                    <xs:element name="Archive" type="xs:string"
                                    dfdl:choiceBranchKey="PK"
                                    dfdl:inputValueCalc="{'Zip archive'}" />
                </xs:choice>
                <xs:element name="Unrecognized" type="xs:string"
                                    dfdl:inputValueCalc="{'Unrecognized magic 
number'}" />
            </xs:choice>
        </xs:sequence>
    </xs:complexType>
</xs:element>




From: Beckerle, Mike <[email protected]>
Sent: Tuesday, September 24, 2019 1:18 PM
To: [email protected]
Subject: [EXT] Re: Why can't the element referenced by dfdl:choiceBranchKey use 
dfdl:inputValueCalc?

A global element is not allowed to have inputValueCalc property.

This is an arbitrary restriction in DFDL. At one point before there were any 
implementations of inputValueCalc property, someone thought this could keep 
implementors out of trouble.

Having implemented this now, I see no reason for this restriction.

DFDL workgroup is supposed to be getting an "experience document" about 
calculated value properties from our experience with it. We have a draft of 
that on the Daffodil Wiki.

See: https://s.apache.org/daffodil-experience-with-computed-elements

Unless it is already there, I will update this page with a note that this 
restriction is unnecessary.

________________________________
From: Costello, Roger L. <[email protected]<mailto:[email protected]>>
Sent: Tuesday, September 24, 2019 1:11 PM
To: [email protected]<mailto:[email protected]> 
<[email protected]<mailto:[email protected]>>
Subject: Why can't the element referenced by dfdl:choiceBranchKey use 
dfdl:inputValueCalc?


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'}" />


Reply via email to