针对Oracle数据库的类型进行XSD限定元素值为空、不为空的方法小结。
1、限定Oracle中类型为Number(7,3)
<xs:simpleType>
<xs:restriction base="xs:decimal">
<xs:pattern value="[0-9]{1,4}([.][0-9]{1,3})?"/>
</xs:restriction>
</xs:simpleType>
2、限定varchar2(2)类型(值不为空,但长度不超过2)
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="2"/>
<xs:pattern value=".+"/>
</xs:restriction>
</xs:simpleType>
3、限定varchar2(2)类型(值可为空,但长度不超过2)
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="2"/>
</xs:restriction>
</xs:simpleType>
4、限定char(4)类型(值不为空,但长度不超过4)
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:length value="4"/>
</xs:restriction>
</xs:simpleType>
5、限定char(4)类型(值可为空,但长度不超过4)
<xs:simpleType name="str4-or-empty">
<xs:union membersType="str4 empty-string">
</xs:simpleType>
<xs:simpleType name="empty-string">
<xs:restriction base="xs:string">
<xs:enumeration value="" />
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="str4">
<xs:restriction base="xs:string">
<xs:length value="4"/>
</xs:restriction>
</xs:simpleType>