Reputation: 22054
I realize that the value 0.00 is not a valid nonNegativeInteger, nor is it even an Integer. Unfortunately, the data is coming in that format. I don't want to throw it away if it ends with .0 but, I also don't want to change the type to Decimal and possibly have values ending in .1 coming in as valid.
Is there a way my XSD can validate numbers such that they are just positive whole numbers, so values of 0.00, 0, 1, 1.0, 2.0000000 etc are all accepted, but -1, 1.1, 2.2, 3.3333 are all invalid?
Thanks -c
Upvotes: 0
Views: 989
Reputation: 22054
This works for what I need, thanks John
<xs:simpleType name="nonNegativeWholeDecimal">
<xs:restriction base="xs:decimal">
<xs:pattern value="[0-9]*(\.[0]*)?"/>
</xs:restriction>
</xs:simpleType>
Upvotes: 0
Reputation: 161773
You could look at changing to decimal and placing a restriction on the places after the decimal point. In particular, you might be able to use a regex facet. I've never tried this, and don't even know if it's valid, but it's a direction to look at. You'd be restricting the lexical space rather than the value space, but that's what you want.
Upvotes: 1