<?xml version="1.0" encoding="UTF-8"?>
<?xml:namespace prefix = xs /><xs:schema xmlns:xs=" http://www.w3.org/2001/XMLSchema">
<xs:element name="number" type="zeroPositive"></xs:element>
<xs:simpleType name="zero">
<xs:restriction base="xs:string">
<xs:pattern value="0+"></xs:pattern>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="zeroPositive">
<xs:union memberTypes="xs:positiveInteger zero"></xs:union>
</xs:simpleType>
</xs:schema>
<?xml:namespace prefix = xs /><xs:schema xmlns:xs=" http://www.w3.org/2001/XMLSchema">
<xs:element name="number" type="zeroPositive"></xs:element>
<xs:simpleType name="zero">
<xs:restriction base="xs:string">
<xs:pattern value="0+"></xs:pattern>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="zeroPositive">
<xs:union memberTypes="xs:positiveInteger zero"></xs:union>
</xs:simpleType>
</xs:schema>
本文介绍了一种使用XML Schema定义元素的方法,重点在于如何通过正则表达式限制字符串类型,并结合简单类型和正则表达式创建联合类型。通过对zeroPositive类型的定义,展示了如何让一个元素接受零或正整数。
878

被折叠的 条评论
为什么被折叠?



