【问题标题】:Include restrictions as attribute包括限制作为属性
【发布时间】:2013-03-11 09:41:27
【问题描述】:

我有一个问题:是否可以将限制设置为属性?例如:

<xs:element name="test">
 <xs:complexType>
  <xs:sequence minOccurs="0" maxOccurs="1">
    <xs:element name="elem1" type="xs:integer" minInclusive="0" maxInclusive="3"/>
    <xs:element name="elem2" type="type="xs:normalizedString" minlength="1" maxlength="7"/>
  </xs:sequence>
 <xs:complexType>
<xs:element>

这似乎不起作用,但我有很多“elems(x)”,我想避免为每个 sympletype 定义,包括限制。

【问题讨论】:

    标签: xml xsd restriction


    【解决方案1】:

    不,不可能像您所描绘的那样;相反,您可以做的是定义一个全局(命名)简单类型来捕获您想要的约束,然后在您想要的地方引用它,就像使用内置类型一样。

    <xsd:simpleType name="tt">
       <xsd:restriction base="xsd:normalizedString">
          <xsd:minLength value="1"/>
          <xsd:maxLength value="7"/>
       </xsd:restriction>
    </xsd:simpleType>
    
    
    <xsd:element name="elem2" type="tt"/>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-03-17
      • 1970-01-01
      • 2019-06-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-03-26
      相关资源
      最近更新 更多