XML Schema restriction 元素
定义和用法
restriction 元素定义对 simpleType、simpleContent 或 complexContent 定义的约束。
元素信息
出现次数 | 一次 |
父元素 | complexContent |
内容 | group、all、choice、sequence、attribute、attributeGroup、anyAttribute |
语法
ປະເພດອື່ນໆ > Content for simpleType: (annotation?,(simpleType?,(minExclusive|minInclusive| maxExclusive|maxInclusive|totalDigits|fractionDigits| length|minLength|maxLength|enumeration|whiteSpace|pattern)*)) Content for simpleContent: (annotation?,(simpleType?,(minExclusive |minInclusive| maxExclusive|maxInclusive|totalDigits|fractionDigits| length|minLength|maxLength|enumeration|whiteSpace|pattern)*)?, ((attribute|attributeGroup)*,anyAttribute?)) Content for complexContent: (annotation?,(group|all|choice|sequence)?, ((attribute|attributeGroup)*,anyAttribute?))
(? 符号声明在 restriction 元素中该元素可出现零次或一次。)
ລະຫັດ | ອະທິບາຍ |
---|---|
ID | ຄວາມຄິດ. ຄົ້ນຫາ ID ສະບາຍອັນສະບາຍຂອງປະເພດດັ່ງກ່າວ: |
ພື້ນຖານ | ຄວາມຄິດ. ຄົ້ນຫາຊື່ປະເພດທຳມະດາ, simpleType ຫຼື complexType ທີ່ມີຄວາມຄິດໃນ schema (ຫຼື schema ອື່ນໆທີ່ຈະອະທິບາຍໂດຍບໍລິສັດ): |
ປະເພດອື່ນໆ | ຄວາມຄິດ. ຄົ້ນຫາປະເພດອື່ນໆທີ່ມີຄວາມຄິດພາຍໃນບໍລິສັດທີ່ບໍ່ມີຄວາມຄິດມະນາສາດ: |
ຄວາມນັບ
ຄວາມນັບ 1
ບົດສະຫຼຸບນີ້ກໍານົດປະເພດ "age" ທີ່ມີຄວາມຄິດ. ຄູ່ມູນ "age" ບໍ່ສາມາດຕໍ່າຫຼຸດກວ່າ 0 ຫຼືຫຼຸດຫຼາຍກວ່າ 100:
<xs:element name="age"> <xs:simpleType> <xs:restriction base="xs:integer"> <xs:minInclusive value="0"/> <xs:maxInclusive value="100"/> </xs:restriction> </xs:simpleType> </xs:element>
ຄວາມນັບ 2
ບົດສະຫຼຸບນີ້ກໍານົດປະເພດ "initials". "initials" ມີຄວາມຄິດ. ຄູ່ມູນທີ່ມີຄວາມຄິດຈະຢູ່ຢູ່ທີ່ a ຫາ z ທີ່ສະແດງຄຳຂອງພາສາລາວ:
<xs:element name="initials"> <xs:simpleType> <xs:restriction base="xs:string"> <xs:pattern value="[a-zA-Z][a-zA-Z][a-zA-Z]"/> </xs:restriction> </xs:simpleType> </xs:element>
ຄວາມນັບ 3
ບົດສະຫຼຸບນີ້ກໍານົດປະເພດ "password". "password" ມີຄວາມຄິດ. ຄູ່ມູນຕ້ອງມີຄວາມສາມາດສູງສຸດ 5 ຄັນສາມາດ ແລະຕໍ່າສຸດ 8 ຄັນສາມາດ:
<xs:element name="password"> <xs:simpleType> <xs:restriction base="xs:string"> <xs:minLength value="5"/> <xs:maxLength value="8"/> </xs:restriction> </xs:simpleType> </xs:element>
ຄວາມນັບ 4
ບົດສະຫຼຸບນີ້ສະແດງວ່າມີການກໍານົດຮູບແບບມີຄວາມຄິດຫຼາຍຫຼັກ. ຮູບແບບ "Chinese_customer" ໄດ້ຍິນວັດຖຸຈາກຮູບແບບ "customer" ທຳມະດາ, ປະກອບສ່ວນ "country" ມີຄວາມຄິດຄົງເປັນ "China":
<xs:complexType name="customer"> <xs:sequence> <xs:element name="firstname" type="xs:string"/> <xs:element name="lastname" type="xs:string"/> <xs:element name="country" type="xs:string"/> </xs:sequence> </xs:complexType> <xs:complexType name="Chinese_customer"> <xs:complexContent> <xs:restriction base="customer"> <xs:sequence> <xs:element name="firstname" type="xs:string"/> <xs:element name="lastname" type="xs:string"/> <xs:element name="country" type="xs:string" fixed="China"/> </xs:sequence> </xs:restriction> </xs:complexContent> </xs:complexType>