学习笔记——XML Schema自定义简单数据类型

本文详细介绍了XML Schema中的自定义数据类型,包括限制<restriction/>、列表<list/>和联合<union/>。fractionDigits和totalDigits约束用于限定数值精度,whiteSpace约束则规定了字符串中空白的处理方式。在限制派生中,通过添加约束创建新类型;列表由单个数据类型扩展,需要注意whiteSpace约束;联合类型由多种成员类型组成,其值可为任意成员类型的值。
摘要由CSDN通过智能技术生成

XML Schema规范共推荐12种约束。

范围约束

minInclusice、manInclusice、minExclusive、maxExcusive

长度约束 length、minLength、maxLength
精度约束 fractionDigits、totalDigits
枚举约束 enumeration
正则表达式约束 pattern
空白处理 whiteSpace

 

fractionDigits:用于定义十进制数小数部分的精度。

totalDigits:用于指定decimal及其派生类型的数值精度。

whiteSpace:指定字符串中空白的处理方式,preserve(保留空白)、replace(字符串中Newline、tab和carriage-return都会被替换成空白)、collapse(字符串中Newline、tab和carriage-return都会被替换成空白,并且字符串中间连续的空白会被压缩成一个,字符串前后的空白会被自动删除)。

 

 约束的使用方式:

 

<xs:facet value="option" />

 

Table B1.a. Simple Types & Applicable Facets
Simple Types Facets
  length minLength maxLength pattern enumeration whiteSpace
string y y y y y y
normalizedString y y y y y y
token y y y y y see (1)
base64Binary y y y y y see (1)
hexBinary y y y y y see (1)
integer       y y see (1)
positiveInteger       y y see (1)
negativeInteger       y y see (1)
nonNegativeInteger       y y see (1)
nonPositiveInteger       y y see (1)
long       y y see (1)
unsignedLong       y y see (1)
int       y y see (1)
unsignedInt       y y see (1)
short       y
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值