krasa / krasa-jaxb-tools

XJC / JAXB plugin for generation of Bean Validation Annotations (JSR-303) and replacing primitive types
Apache License 2.0
60 stars 49 forks source link

Wrong integral digits in Digit-Annotation in combination of totalDigits and fractionDigits in XSD #71

Closed j-ferreira closed 4 years ago

j-ferreira commented 4 years ago

According to the documentation the totalDigits contains the fractionDigits: "xs:totalDigits defines the maximum number of digits of decimal and derived datatypes (both after and before the decimal point, not counting the decimal point itself)." https://www.oreilly.com/library/view/xml-schema/0596002521/re52.html At the moment totalDigits value in the xsd will be copied one-to-one into the integer attribute of Digit annotation without checking the fractionDigits of xsd. That means when following is set into the xsd:

<xs:element name="exampleElement">
    <xs:simpleType>
        <xs:restriction base="xs:decimal">
            <xs:totalDigits value="10"/>
            <xs:fractionDigits value="2"/>
        </xs:restriction>
    </xs:simpleType>
</xs:element>

the JAXB class gets then the following annotation:

@Digits(integer = 10, fraction = 2)

But in these case following annotation would be correct:

@Digits(integer = 8, fraction = 2) Because the integer attribute are only the integral digits and doesn't include the fraction digits.

j-ferreira commented 4 years ago

I close these issue, I already found these issue https://github.com/krasa/krasa-jaxb-tools/issues/40 and now I understand the problematics.