xsd文档定义schema方式

<?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>

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值