I think this partly goes back to well-formed vs valid. One could argue
that a 2 digit number is a form of validation and so you wouldn't want
to necessarily fail the parse as long as it looked like some kind of
number. So I would advocate for removing the assert to get a successful
parse, but enable validation to cause a validation on certain numbers if
that's what you wanted.
That said, if you really did want to cause a parse error this is
probably the best way to do it. I don't believe you can mimic the
totalDigits restriction with just DFDL text properties.
You could get a similar behavior with dfdl:lengthKind="pattern":
dfdl:lengthPattern="[+-]?[0-9]{1,2}"
And an assert the the matched pattern length is greater than zero. But I
personally prefer yours over pattern lengths. I think the intention of
checkConstraints + restrictions is much more clear.
- Steve
On 8/19/19 9:15 AM, Costello, Roger L. wrote:
> Hello DFDL community,
>
> My input consists of an integer up to 2 digits. These are all legal input
> values:
>
> 0, 99, +99, -99, 1, -1
>
> The below DFDL schema exploits XML Schema validation. It's simple and works
> perfect. I believe that the input cannot be described using just the DFDL
> text number properties. Do you agree? /Roger
>
> <xs:element name="Number">
> <xs:simpleType>
> <xs:annotation>
> <xs:appinfo source="http://www.ogf.org/dfdl/">
> <dfdl:assert test="{ dfdl:checkConstraints(.) }"/>
> </xs:appinfo>
> </xs:annotation>
> <xs:restriction base="xs:integer">
> <xs:totalDigits value="2" />
> </xs:restriction>
> </xs:simpleType>
> </xs:element>
>