Thanks Brandon. I created a Powerpoint slide that attempts to summarize the 
issue of validation. See below. Is it correct?  /Roger

[cid:[email protected]]

From: Sloane, Brandon <[email protected]>
Sent: Monday, May 13, 2019 11:06 AM
To: [email protected]
Subject: [EXT] Re: How come unparsing invalid XML doesn't produce an error?


dfdl:outputValueCalc is not used to validate the value in the input infoset, 
but rather to replace the value in the input infoset.



The intent of dfdl:outputValueCalc is for things such as length fields, where 
editing the infoset could change the desired value in a way that we want to be 
able to automatically compute during unparse. In such a use case, it would be 
undesirable to require that the value in the infoset matches the result of 
dfdl:outputValueCalc, as that would require manually computing the length field 
before unparsing, which is what we want to avoid.



Unfortunately, this means that the original value of the field is generally not 
available during unparse. In particular, during unparse, validation occurs on 
the augmented infoset, which is constructed by (among other things) replacing 
the logical values with the result of dfdl:outputValueCalc.



If you want to verify the contents of a field with dfdl:ouputValueCalc during 
unparse, you need to do so prior to running daffodil (eg. through normal xsd 
schema validation).



For fixed elements, such as in your example, an alternative would be to make 
the element hidden. That way there is no opportunity for it to become edited.



If you want to do the validation in Daffodil and keep the element visible, that 
is probably possible by defining it as a hidden field, and creating a second, 
visible, field that is populated using dfdl:inputValueCalc.





________________________________
From: Costello, Roger L. <[email protected]<mailto:[email protected]>>
Sent: Monday, May 13, 2019 9:57:37 AM
To: [email protected]<mailto:[email protected]>
Subject: How come unparsing invalid XML doesn't produce an error?


Hello DFDL community,



This is a follow-up to the thread that Christofer started last week about 
"fixed" values.



My input file consists of integers, on different lines. The first value in the 
file must be 44.



Using --Validate limited, I get an error message when the first value is not 44.



If the XML document is invalid (the first element does not have a value of 44), 
then I want unparsing to generate an error. I thought that Steve said the way 
to achieve this is to use:



dfdl:outputValueCalc="{ 44 }"



However, that does not result in an error. Why not?



Here is my DFDL schema:



<xs:element name="input">
    <xs:complexType>
        <xs:sequence dfdl:separator="%NL;" dfdl:separatorPosition="infix">
            <xs:element name="Fixed-Value" dfdl:occursCountKind="implicit"
                                  dfdl:outputValueCalc="{ 44 }">
                <xs:simpleType>
                    <xs:restriction base="xs:byte">
                        <xs:minInclusive value="44" />
                        <xs:maxInclusive value="44" />
                    </xs:restriction>
                </xs:simpleType>
            </xs:element>
            <xs:element name="num" type="xs:string" maxOccurs="unbounded"
                                  dfdl:occursCountKind="implicit" />
        </xs:sequence>
    </xs:complexType>
</xs:element>




Reply via email to