zoukankan      html  css  js  c++  java
  • XSD的学习

    一 基础概念

    schema:root element of each xml schema.and contain several attributes.like xmlns:xs,targetNameSpace,xmlns,elementFormDefault.
    element:it have single element and complext element.And the element type can be string,decimal,integer,boolean,date,time.
    attribute:used in the element.like element,it can use many types.
    restrictions:<xs:restriction>,<xs:minInclusive>,<xs:maxInclusive>,<xs:simpleType>,<xs:pattern>
    simpleType:element,attribute,restriction.
    group:a group element.
    attributeGroup:a set of attribute declarations.
    choice:allow only one element contained in the <choice> declaration.
    complexType:a complexType is an XML element that contains other elements or attributes.
    union:defines a simple type as a collection (union) of values from specified simple data types
    unique:an element or an attribute value must be unique within the scope.
    sequence:the child elements must appear in a sequence

    二:具体的XSD

    <xs:schema xmlns:xs="">

    <xs:group name="custGroup">
    <xs:sequence>
    <xs:element name="customer" type="xs:string"/>
    <xs:element name="orderdetails" type="xs:string"/>
    <xs:element name="billto" type="xs:string"/>
    <xs:element name="shipto" type="xs:string"/>
    </xs:sequence>
    </xs:group>


    <xs:element name="name" type="xs:string" default="Zhangsan>
    <xs:attribute name="sex" type="xs:string" default="male" use="required"></xs:attribute>

    </xs:element>

    <xs:element name="age" type="xs:integer">
    <xs:simpleType>
    <xs:restriction base="xs:integer">
    <xs:minInclusive value="0"/>
    <xs:maxInclusive value="120"/>
    </xs:restriction>
    </xs:simpleType>
    <xs:element>

    <xs:complexType name="ordertype">
    <xs:group ref="custGroup"/>
    <xs:attribute name="status" type="xs:string"/>
    </xs:complexType>

    <xs:attributeGroup name="personattr">
    <xs:attribute name="attr1" type="string"/>
    <xs:attribute name="attr2" type="integer"/>
    </xs:attributeGroup>

    <xs:complexType name="person">
    <xs:attributeGroup ref="personattr"/>
    </xs:complexType>

    <xs:element name="person">
    <xs:complexType>
    <xs:choice>
    <xs:element name="employee" type="employee"/>
    <xs:element name="member" type="member"/>
    </xs:choice>
    </xs:complexType>
    </xs:element>

    <xs:element name="jeans_size">
    <xs:simpleType>
    <xs:union memberTypes="sizebyno sizebystring" />
    </xs:simpleType>
    </xs:element>

    <xs:simpleType name="sizebyno">
    <xs:restriction base="xs:positiveInteger">
    <xs:maxInclusive value="42"/>
    </xs:restriction>
    </xs:simpleType>

    <xs:simpleType name="sizebystring">
    <xs:restriction base="xs:string">
    <xs:enumeration value="small"/>
    <xs:enumeration value="medium"/>
    <xs:enumeration value="large"/>
    </xs:restriction>
    </xs:simpleType>

    <xs:unique name="IDUnique">
    <xs:selector xpath="学生"/>
    <xs:field xpath="@学号"/>
    </xs:unique>

    <xs:element name="personinfo">
    <xs:complexType>
    <xs:sequence>
    <xs:element name="firstname" type="xs:string"/>
    <xs:element name="lastname" type="xs:string"/>
    <xs:element name="address" type="xs:string"/>
    <xs:element name="city" type="xs:string"/>
    <xs:element name="country" type="xs:string"/>
    </xs:sequence>
    </xs:complexType>
    </xs:element>

    </xs:schema>

  • 相关阅读:
    UVa OJ 148 Anagram checker (回文构词检测)
    UVa OJ 134 LoglanA Logical Language (Loglan逻辑语言)
    平面内两条线段的位置关系(相交)判定与交点求解
    UVa OJ 130 Roman Roulette (罗马轮盘赌)
    UVa OJ 135 No Rectangles (没有矩形)
    混合函数继承方式构造函数
    html5基础(第一天)
    js中substr,substring,indexOf,lastIndexOf,split等的用法
    css的textindent属性实现段落第一行缩进
    普通的css普通的描边字
  • 原文地址:https://www.cnblogs.com/SoulSpirit/p/2935609.html
Copyright © 2011-2022 走看看