Ankit
Ankit

Reputation: 11

xsd:double restriction to six decimal place

I have a case where I want to put restriction on XSd:double element. The precision should be 6 decimal place and should throw an exception if more than 6 decimal places entered or should be appended with 0's if less than 6 decimal places entered.

Is it possible to achieve through xsd restrictions?

Upvotes: 1

Views: 1525

Answers (1)

Michael Kay
Michael Kay

Reputation: 163625

It's a rather strange requirement: if decimal places matter so much, I would expect you to be using xs:decimal rather than xs:double, in which case you can use the totalDigits and fractionDigits facets to restrict the value.

If you want to restrict xs:double in this way, you will have to do it using a pattern (regular expression).

Upvotes: 1

Related Questions