zoukankan      html  css  js  c++  java
  • SChema 多个属性的设置学习

    <?xml version="1.0" encoding="UTF-8"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
        <xs:element name="学生集合">
            <xs:complexType>
                <xs:sequence minOccurs="1" maxOccurs="unbounded">
                    <xs:element ref="学生"/>
                    <xs:element ref="老师" minOccurs="0"/>
                </xs:sequence>
            </xs:complexType>
        </xs:element>
        <xs:element name="学生">
            <xs:complexType>
                <xs:sequence>
                    <xs:element name="姓名" type="xs:string"/>
                    <xs:element name="性别">
                        <xs:simpleType>
                            <xs:restriction base="xs:string">
                                <xs:enumeration value="男"/>
                                <xs:enumeration value="女"/>
                            </xs:restriction>
                        </xs:simpleType>
                    </xs:element>
                    <xs:element name="年龄">
                        <xs:simpleType>
                            <xs:restriction base="xs:integer">
                                <xs:minExclusive value="0"/>
                                <xs:maxExclusive value="120"/>
                            </xs:restriction>
                        </xs:simpleType>
                    </xs:element>
                </xs:sequence>
                <xs:attribute name="学号" type="xs:string" use="required"/>
            </xs:complexType>
        </xs:element>
        <xs:element name="老师">
            <xs:complexType>
                <xs:sequence>
                    <!-- 多个属性的设置,多个属性的时候type就不能有类型了 -->
                    <xs:element name="姓名">
                        <xs:complexType>
                                <xs:attributeGroup ref="personattrgroup"/>
                        </xs:complexType>    
                    </xs:element>
                    <xs:element name="性别">
                        <xs:simpleType>
                            <xs:restriction base="xs:string">
                                <xs:enumeration value="男"/>
                                <xs:enumeration value="女"/>
                            </xs:restriction>
                        </xs:simpleType>
                    </xs:element>
                    <xs:element name="年龄">
                        <xs:simpleType>
                            <xs:restriction base="xs:integer">
                                <xs:minExclusive value="0"/>
                                <xs:maxExclusive value="120"/>
                            </xs:restriction>
                        </xs:simpleType>
                    </xs:element>
                </xs:sequence>
                <xs:attribute name="教工号" type="xs:string" use="required"/>
            </xs:complexType>
        </xs:element>
        <xs:attributeGroup name="personattrgroup">
              <xs:attribute name="firstname" type="xs:string"/>
              <xs:attribute name="lastname" type="xs:string"/>
              <xs:attribute name="birthday" type="xs:date"/>
        </xs:attributeGroup>
    </xs:schema>

    在姓名处设置了多个属性

    <?xml version="1.0" encoding="UTF-8"?>
    <学生集合 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="file:///C:/Users/Administrator/Documents/Altova/XMLSpy2011/Examples/studentNode.xsd">
        <学生 学号="A1">
            <姓名>CIACs</姓名>
            <性别></性别>
            <年龄>22</年龄>
        </学生>
        <老师 教工号="A8">
            <姓名 firstname="zhangsan" lastname="lisi" birthday="1998-06-07"></姓名>
            <性别></性别>
            <年龄>15</年龄>
        </老师>
        <学生 学号="A1">
            <姓名>CIACs</姓名>
            <性别></性别>
            <年龄>22</年龄>
        </学生>
        <学生 学号="A1">
            <姓名>CIACs</姓名>
            <性别></性别>
            <年龄>22</年龄>
        </学生>
    </学生集合>
  • 相关阅读:
    用Python完成Excel的常用操作
    用Python实现excel 14个常用操作
    ubuntu and centos各种上网代理设置
    vim 熟练度练习
    Ansible-playbook 使用方式 看一篇就够了
    python 使用ldap3 查询跨域的用户信息
    python pyinstaller 的使用
    vs code新建python虚拟环境
    vs code 远程开发环境设置
    上下文管理器(Context Manager)
  • 原文地址:https://www.cnblogs.com/bksqmy/p/4546000.html
Copyright © 2011-2022 走看看