How to define a varying length of the string in XSD pattern?
- by infant programmer
The input XML tag must be validated for a pattern which is like this:
type : positive int / decimal, minimum length is 0, max length is 12(before decimal point), fraction digits are optional if exist then precision must be 2. This means both positive integer and Decimal numbers(2 digit precision) are allowed.
so the acceptable values can be like,
null, 0, 0.00, 1234567890, 123456789012, 123456789012.12,
invalid values are:
0.000, 1234567890123(13 digits - invalid),
The pattern I have designed is:
<xs:pattern value="|([0-9]){12}|([0-9]){12}[.][0-9][0-9]"/>
The problem with this pattern is, it doesn't allow the number with string-length less than 12, it says "1234567890" is an invalid value, where as it must be allowed!