Search code examples
xsdxsd-validationfractionsaltova

XSD validation: total digits and fraction digits


I have got an XSD restriction definition:

<xs:restriction base="xs:decimal">
  <xs:totalDigits value="15"/>
  <xs:fractionDigits value="2"/>
</xs:restriction>

the following XML fragment is considered to be valid by my XSD processor (namely, Altova XML Spy):

<MySum>123456789012345.00</MySum>

although it has a total of 17 digits. However,

<MySum>123456789012345.01</MySum>

is considered to be invalid.

Is the processor's behaviour correct? I thought it should not try to round the values


Solution

  • According to https://www.w3.org/TR/xmlschema-2/#rf-fractionDigits that "adding ... leading zero digits or trailing fractional zero digits is still permitted". So the behaviour seems to be correct.