开发者

Making sure a number is multiple of 8 via xml schema

I have a tag in one of the xml files and for that the XSD file contains the following line

<xs:element name="startBit" type="xs:integer"/>

Right now, I am parsing the data in the startBit field and then checking whether it is a multiple of 8 or not by checking if the number mod 8 equals 0.

I was wondering whether I cou开发者_运维技巧ld put a rule/restriction in the xml schema itself to make sure that the number is a multiple of 8.


There is no way to do this with XML Schema, unless you can restrict the range of the numbers. For instance, you could enumerate the numbers from 0 to 255 which are a multiple of 8, but there's clearly no way to do that for the numbers from 0 to 2^32-1.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜