【问题标题】:How to define an integer range in XML / XSD?如何在 XML / XSD 中定义整数范围?
【发布时间】:2019-02-17 02:57:13
【问题描述】:

我目前在 XSD 中有这个:

<xs:element name="qty" maxOccurs="1" minOccurs="1" />

如何添加一个规则,同时只允许 Qty 的值介于 100 到 2000 之间?

【问题讨论】:

    标签: xml xsd xsd-validation xml-validation


    【解决方案1】:

    xs:restrictionxs:{min|max}{In|Ex}clusive 一起使用:

      <xs:simpleType name="Quantity100to2000">
        <xs:restriction base="xs:integer">
          <xs:minExclusive value="100"/>
          <xs:maxExclusive value="2000"/>
        </xs:restriction> 
      </xs:simpleType>
    
      <xs:element name="qty" maxOccurs="1" minOccurs="1" type="Quantity100to2000"/>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-11-10
      • 1970-01-01
      • 2021-11-07
      • 1970-01-01
      • 1970-01-01
      • 2015-04-02
      • 2014-10-08
      • 1970-01-01
      相关资源
      最近更新 更多