We need to show the infoset element as part of the assertion failure message, specifically for an assertion on an element of simple type.
(For an assert on a complex type element, or a sequence or choice, it's trickier. There I think we could show the infoset object, but as in many places where we need to show this, we need to be able to elide unnecessary substructure or parent structure. Otherwise these will get big and unweildy. - separate JIRA issue should we decide to go there.)
-------------------------------------
From: Garriss Jr., James P. [jgarriss@mitre.org]
Sent: Friday, June 07, 2013 10:23 AM
To: Mike Beckerle; Stephen Lawrence
Subject: [daffodil 0.10] Error message improvement suggestion
I have this simple input:
MIME-Version: dog
Obviously invalid. I’m describing it with this schema:
<xsd:element name="MimeVersion" dfdl:initiator="MIME-Version:%SP;" dfdl:terminator="%NL;" dfdl:length="3" dfdl:lengthKind="explicit">
<xsd:annotation>
<xsd:appinfo source="http://www.ogf.org/dfdl/dfdl-1.0/">
<dfdl:assert test="
" message="MIME-Version must have a value of '1.0'."/>
</xsd:appinfo>
</xsd:annotation>
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:enumeration value="1.0"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
The error message I get is:
[error] Parse Error: Assertion failed. MIME-Version must have a value of '1.0'.
Schema context: element.MimeVersion Location line 13 column 135 in file:/C:/…/MimeVersion.xsd
Data location was preceding byte 19
UTF-8 text starting at byte 16 is: (g
)
Data (hex) starting at byte 16 is: (0x670D0A)
Getting my assertion message back is helpful, as it tells me what the right value should be. But I think this error could be improved by also telling me what value was found. Perhaps the message could look at bit more like this:
[parsing error] While processing the MimeVersion element, the value “dog” was found.
This fails the assertion: MIME-Version must have a value of '1.0'.
Schema: Location line 13 column 135 in file:/C:/…/MimeVersion.xsd