<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://www.example.org/1"
elementFormDefault="qualified">
<!--
如果声明部分为: <schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
则下面节点和属性必须加上XS:
-->
<element name="ISBN">
<simpleType>
<restriction base="string">
<pattern value="[0-9]-[0-9]{3}-[0-9]{5}-[0-9]"></pattern>
</restriction>
</simpleType>
</element>
<element name="author" type="string"></element>
<complexType name="bookType">
<sequence>
<element ref="bookName"></element>
<element ref="author"></element>
<element ref="ISBN"></element>
<element ref="price"></element>
<element ref="quantity"></element>
</sequence>
<attribute name="id" use="required">
<simpleType>
<restriction base="string">
<pattern value="[0-9]{3}"></pattern>
</restriction>
</simpleType>
</attribute>
<attribute name="type" use="required">
<simpleType>
<restriction base="string">
<enumeration value="IT"></enumeration>
<enumeration value="education"></enumeration>
<enumeration value="novel"></enumeration>
</restriction>
</simpleType>
</attribute>
</complexType>
<element name="books">
<complexType>
<sequence>
<element name="book" type="bookType" maxOccurs="unbounded"
minOccurs="1"></element>
</sequence>
</complexType>
</element>
<element name="bookName" type="string"></element>
<element name="price">
<simpleType>
<restriction base="decimal">
<fractionDigits value="2">
</fractionDigits>
</restriction>
</simpleType>
</element>
<element name="quantity">
<simpleType>
<restriction base="byte">
<maxExclusive value="100"></maxExclusive>
<minExclusive value="0"></minExclusive>
</restriction>
</simpleType>
</element>
</schema>
xsd文档定义schema方式
最新推荐文章于 2021-06-27 15:40:45 发布