开发者

Xml pattern restriction. Pattern for "x.x" like attribute value representing a version number

开发者 https://www.devze.com 2022-12-09 23:08 出处:网络
I have an XML开发者_JAVA技巧 attribute representing the version numbering of a file. The file version is identified internally by two byte fields so that, theoretically the versión could go from: 0.

I have an XML开发者_JAVA技巧 attribute representing the version numbering of a file.

The file version is identified internally by two byte fields so that, theoretically the versión could go from: 0.1 to 255.255.

Is there any way to express that as a pattern restriction or any other kind of restriction in an XML Schema?

Note: The problem is not restricting the format to three numbers, a dot and another three numbers. The problem is disallowing values greater than 255...


I think this should do the trick (not had a chance to check I'm afraid)...

<xs:simpleType name="version">
    <xs:restriction base="xs:string">
        <xs:pattern value="([01]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])[.]([01]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])"/>
    </xs:restriction>
</xs:simpleType>
0

精彩评论

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