zoukankan      html  css  js  c++  java
  • XML Schema choice 元素

    XSD :

    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:sch="http://www.ascc.net/xml/schematron" elementFormDefault="qualified">
    <xsd:simpleType name="employee">
        <xsd:restriction base="xsd:string">    
        </xsd:restriction>
      </xsd:simpleType>
     <xsd:simpleType name="member">
         <xsd:restriction base="xsd:string">
        </xsd:restriction>
      </xsd:simpleType>
    <xsd:element name="person">
      <xsd:complexType>
        <xsd:choice minOccurs="2" maxOccurs="2">
          <xsd:element name="employee" type="employee"/>
          <xsd:element name="member" type="member"/>
        </xsd:choice>
      </xsd:complexType>
    </xsd:element>
    </xsd:schema>
    View Code

    minOccurs="2" maxOccurs="2" 用于限定 choice里面元素在父元素中出现的次数。

    Example:

    <?xml version="1.0" ?>
    <person>
    <member></member>
    <member></member>
    </person>
    View Code

    验证通过。

    <?xml version="1.0" ?>
    <person>
    <employee></employee>
    <member></member>
    </person>
    View Code

    验证通过。

    <?xml version="1.0" ?>
    <person>
    <employee></employee>
    </person>
    View Code

    验证失败。

  • 相关阅读:
    clip属性,截取你想要显示的图片
    select背景灰色
    [转]ShowModal() = mrOk
    【转】Delphi-Unit文件结构
    析构方法
    [转]Delphi 7连接MySql /MariaDB
    MySQL/Mariadb遇见的问题
    更换数据库
    FlameRobin
    FireBird初使用
  • 原文地址:https://www.cnblogs.com/harlanc/p/5216707.html
Copyright © 2011-2022 走看看