学习笔记——XML Schema内置数据类型

本文详细介绍了XML Schema的各种内置数据类型,包括string及其相关类型(如normalizedString、token等)、数值类型、time和date类型、boolean类型、anyURL类型以及二进制类型hexBinary和base64Binary。这些类型在XML Schema中用于限制和验证XML文档的结构和内容。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Schema的内置类型继承关系

 

 

 

Schema内置类型说明

 

Table 2. Simple Types Built In to XML Schema
Simple TypeExamples (delimited by commas)Notes
stringConfirm this is electric 
normalizedStringConfirm this is electricsee (3)
tokenConfirm this is electricsee (4)
base64BinaryGpM7 
hexBinary0FB7 
integer...-1, 0, 1, ...see (2)
positiveInteger1, 2, ...see (2)
negativeInteger... -2, -1see (2)
nonNegativeInteger0, 1, 2, ...see (2)
nonPositiveInteger... -2, -1, 0see (2)
long-9223372036854775808, ... -1, 0, 1, ... 9223372036854775807see (2)
unsignedLong0, 1, ... 18446744073709551615see (2)
int-2147483648, ... -1, 0, 1, ... 2147483647see (2)
unsignedInt0, 1, ...4294967295see (2)
short-32768, ... -1, 0, 1, ... 32767see (2)
unsignedShort0, 1, ... 65535see (2)
byte-128, ...-1, 0, 1, ... 127see (2)
unsignedByte0, 1, ... 255see (2)
decimal-1.23, 0, 123.4, 1000.00see (2)
float-INF, -1E4, -0, 0, 12.78E-2, 12, INF, NaNequivalent to single-precision 32-bit floating point, NaN is "not a number", see (2)
double-INF, -1E4, -0, 0, 12.78E-2, 12, INF, NaNequivalent to double-precision 64-bit floating point, see (2)
booleantrue, false, 1, 0 
durationP1Y2M3DT10H30M12.3S1 year, 2 months, 3 days, 10 hours, 30 minutes, and 12.3 seconds
dateTime1999-05-31T13:20:00.000-05:00May 31st 1999 at 1.20pm Eastern Standard Time which is 5 hours behind Co-Ordinated Universal Time, see (2)
date1999-05-31see (2)
time13:20:00.000, 13:20:00.000-05:00see (2)
gYear19991999, see (2) (5)
gYearMonth1999-02the month of February 1999, regardless of the number of days, see (2) (5)
gMonth--05May, see (2) (5)
gMonthDay--05-31every May 31st, see (2) (5)
gDay---31the 31st day, see (2) (5)
NameshipToXML 1.0 Name type
QNamepo:USAddressXML Namespace QName
NCNameUSAddressXML Namespace NCName, i.e. a QName without the prefix and colon
anyURI
http://www.example.com/,
http://www.example.com/doc.html#ID5
 
languageen-GB, en-US, frvalid values for xml:lang as defined in XML 1.0
ID XML 1.0 ID attribute type, see (1)
IDREF XML 1.0 IDREF attribute type, see (1)
IDREFS XML 1.0 IDREFS attribute type, see (1)
ENTITY XML 1.0 ENTITY attribute type, see (1)
ENTITIES XML 1.0 ENTITIES attribute type, see (1)
NOTATION XML 1.0 NOTATION attribute type, see (1)
NMTOKEN
US,
Brésil
XML 1.0 NMTOKEN attribute type, see (1)
NMTOKENS
US UK,
Brésil Canada Mexique
XML 1.0 NMTOKENS attribute type, i.e. a whitespace separated list of NMTOKEN's, see (1)

Notes:

(1) To retain compatibility between XML Schema and XML 1.0 DTDs, the simple types ID, IDREF, IDREFS, ENTITY, ENTITIES, NOTATION, NMTOKEN, NMTOKENS should only be used in attributes.

(2) A value of this type can be represented by more than one lexical format, e.g. 100 and 1.0E2 are both valid float formats representing "one hundred". However, rules have been established for this type that define a canonical lexical format, seeXML Schema Part 2.

(3) Newline, tab and carriage-return characters in a normalizedString type are converted to space characters before schema processing.

 (4) As normalizedString, and adjacent space characters are collapsed to a single space character, and leading and trailing spaces are removed.

(5) The "g" prefix signals time periods in the Gregorian calendar.

 

 

各种内置类型详解

 

1:string及其相关类型

 

string:保留原始字符串。

normalizedString:字符串中Newline、tab和carriage-return都会被替换成空白。

token:字符串中Newline、tab和carriage-return都会被替换成空白,并且字符串中间连续的空白会被压缩成一个,字符串前后的空白会被自动删除。

 

Name:要求是合法的XML签名。

NCName:不带命名空间的XML签名。

QName:带命名空间的XML签名。

 

由string派生出来的ID、IDREF、ENTITY、ENTITIES、NMTOKEN、NMTOKENS类型只能用来约束属性。

ID:标识符。

IDREF:引用另一个ID。

IDREFS:引用多个已有的ID,空格为分隔符。

NMTOKEN:必须是合法的XML名称,只能由字母、数字、_、-、.、:组成。

NMTOKENS:多个NMTOKEN,空格为分隔符。

ENTITY:外部实体。

ENTITIES:多个外部实体,空格为分隔符。

 

2:数值及其相关类型

 

3:time、date类型

 

4:boolean类型

 

5:anyURL类型

 

6:二进制类型

hexBinary

base64Binarg

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值