0

我正在创建 XSD 并定义 ComplexType,并且想知道如何创建限制。

例如,

<xsd:complexType name="MyTestType">
    <xsd:sequence>
        <xsd:element name="Country" type="xsd:string" > 
...

而且,我希望元素“Country”的长度为 1 到 10 个字符。

有没有办法可以在元素上使用 minLength 和 maxLength ?

谢谢。

4

1 回答 1

0

以下代码可以满足您的要求;

<xs:simpleType name="myTestType">
    <xs:restriction base="xs:string">
        <xs:pattern value="([a-z][A-Z])+"/>
        <xs:minLength value="1"/>
        <xs:maxLength value="10" />
    </xs:restriction>
</xs:simpleType>

您可以简化它并编写以下内容;

<xs:simpleType name="myTestType">
    <xs:restriction base="xs:string">
        <xs:pattern value="([a-z][A-Z]){1-10}"/>
    </xs:restriction>
</xs:simpleType>

于 2012-10-10T11:19:51.923 回答