当前位置: 首页 > 网络学院 > XML相关教程 > Schema (XSD) > XSD 日期数据类型

Schema (XSD)
XSD 逻辑值数据类型
XML Schema总结
XML Schema 参考
XSD 验证

Schema (XSD) 中的 XSD 日期数据类型


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-03-01   浏览: 765 ::
收藏到网摘: n/a

Date and time data types are used for values that contain date and time.
日期和时间数据类型用于定义日期和时间值。


Date Data Type
日期数据类型

The date data type is used to specify a date.
日期数据类型用于指定一个具体的日期。

The date is specified in the following form "YYYY-MM-DD" where:
日期由下面的"YYYY-MM-DD"形式指定:

  • YYYY indicates the year
    YYYY :指示年份
  • MM indicates the month
    MM :指示月份
  • DD indicates the day
    DD :指示日期

Note: All components are required!
注意:所有组件都是必要组件。

The following is an example of a date declaration in a schema:
下面是一份在schema中声明日期的案例:

<xs:element name="start" type="xs:date"/>

An element in your document might look like this:
在你的文档中,可能包含这样一个元素:

<start>2002-09-24</start>

Time Zones
时间区

To specify a time zone, you can either enter a date in UTC time by adding a "Z" behind the date - like this:
为了指定一个时间区,你既可以通过在日期之后加上 "Z" 访问 UTC 时间格式的日期,如下所示:

<start>2002-09-24Z</start>

or you can specify an offset from the UTC time by adding a positive or negative time behind the date - like this:
也可以在 UTC 时间之后加、减一个时间值,如下所示:

<start>2002-09-24-06:00</start>
or
<start>2002-09-24+06:00</start>

 


Time Data Type
时间数据类型

The time data type is used to specify a time.
时间数据类型用于指定一个时间。

The time is specified in the following form "hh:mm:ss" where:
时间由下面的"hh:mm:ss"形式指定:

  • hh indicates the hour
    hh :指示小时
  • mm indicates the minute
    mm :指示分钟
  • ss indicates the second
    ss :指示秒钟

Note: All components are required!
注意:所有的组件都是必要组件。

The following is an example of a time declaration in a schema:
下面是在schema内声明时间的案例:

<xs:element name="start" type="xs:time"/>

An element in your document might look like this:
在你的文档中,可能包含下述元素:

<start>09:00:00</start>

Or it might look like this:
或者是这样的:

<start>09:30:10.5</start>

Time Zones
时间区

To specify a time zone, you can either enter a time in UTC time by adding a "Z" behind the time - like this:
为了指定一个时间区,你既可以通过在时间之后加上 "Z" 访问 UTC 时间格式的日期,如下所示:

<start>09:30:10Z</start>

or you can specify an offset from the UTC time by adding a positive or negative time behind the time - like this:
也可以UTC时间后加、减一个时间值,如下所示:

<start>09:30:10-06:00</start>
or
<start>09:30:10+06:00</start>

 


DateTime Data Type
日期时间数据类型

The dateTime data type is used to specify a date and a time.
日期时间数据类型用于指定一个日期值和一个时间值。

The dateTime is specified in the following form "YYYY-MM-DDThh:mm:ss" where:
日期时间由"YYYY-MM-DDThh:mm:ss"的形式指定:

  • YYYY indicates the year
    YYYY :指示时间
  • MM indicates the month
    MM :指示月份
  • DD indicates the day
    DD :指示时间
  • T indicates the start of the required time section
    T 用于指示时间区的开头
  • hh indicates the hour
    hh :指示小时
  • mm indicates the minute
    mm :指示分钟
  • ss indicates the second
    ss :指示秒钟

Note: All components are required!
注意:所有组件都是必要组件。

The following is an example of a dateTime declaration in a schema:
下面列举了schema内的日期时间声明的案例:

<xs:element name="startdate" type="xs:dateTime"/>

An element in your document might look like this:
在你的文档中,或许包含了下述元素:

<startdate>2002-05-30T09:00:00</startdate>

Or it might look like this:
或者是这样的:

<startdate>2002-05-30T09:30:10.5</startdate>

Time Zones
时间区

To specify a time zone, you can either enter a dateTime in UTC time by adding a "Z" behind the time - like this:
为指定一个时间区,你既可以通过在时间的后面加个 "Z" 访问 UTC 时间格式的日期,如下所示:

<startdate>2002-05-30T09:30:10Z</startdate>

or you can specify an offset from the UTC time by adding a positive or negative time behind the time - like this:
也可以UTC时间后加、减一个时间值,如下所示:

<startdate>2002-05-30T09:30:10-06:00</startdate>
or
<startdate>2002-05-30T09:30:10+06:00</startdate>

 


Duration Data Type
持续时间数据类型(或“时间段数据类型”)

The duration data type is used to specify a time interval.
持续时间数据类型(或“时间段数据类型”)用于定义一段时间间隔。

The time interval is specified in the following form "PnYnMnDTnHnMnS" where:
时间间隔是由"PnYnMnDTnHnMnS"形式定义的,解释如下:

  • P indicates the period (required)
    P :指示周期(必要参数)
  • nY indicates the number of years
    nY :指示年数
  • nM indicates the number of months
    nM :指示月数
  • nD indicates the number of days
    nD :指示天数
  • T indicates the start of a time section (required if you are going to specify hours, minutes, or seconds)
    T :指示时间片断的开头(如果你需要指定时间、分钟或秒,就必须使用T)
  • nH indicates the number of hours
    nH :指示小时数
  • nM indicates the number of minutes
    nM :指示分钟数
  • nS indicates the number of seconds
    nS :指示秒数

The following is an example of a duration declaration in a schema:
下面是schema内的时间段声明的案例:

<xs:element name="period" type="xs:duration"/>

An element in your document might look like this:
在你的文档中或许包含下述元素:

<period>P5Y</period>

The example above indicates a period of five years.
上述案例指定了5年的时间段:

Or it might look like this:
或者也可以像这样:

<period>P5Y2M10D</period>

The example above indicates a period of five years, two months, and 10 days.
上述案例指定了5年2个月零10天的时间段。

Or it might look like this:
它也可以是这样:

<period>P5Y2M10DT15H</period>

The example above indicates a period of five years, two months, 10 days, and 15 hours.
上述案例指定了5年2个月零10天又15个小时的时间段。

Or it might look like this:
或者它可以是这样:

<period>PT15H</period>

The example above indicates a period of 15 hours.
上述案例指定了15个小时的时间段。

Negative Duration
负时间段

To specify a negative duration, enter a minus sign before the P:
如果要定义负时间段,那就需要在P之前添加一个负号:

<period>-P10D</period>

The example above indicates a period of minus 10 days.
上述案例指定了负10天的时间段。


Date and Time Data Types
日期和时间数据类型

Name
名称
Description
解释
date Defines a date value
定义日期值
dateTime Defines a date and time value
定义日期值和时间值
duration Defines a time interval
定义时间间隔
gDay Defines a part of a date - the day (DD)
定义日期的一部分——日:day (DD)
gMonth Defines a part of a date - the month (MM)
定义日期的一部分——月:month (MM)
gMonthDay Defines a part of a date - the month and day (MM-DD)
定义日期的一部分——月和日:month and day (MM-DD)
gYear Defines a part of a date - the year (YYYY)
定义日期的一部分—— 年:year (YYYY)
gYearMonth Defines a part of a date - the year and month (YYYY-MM)
定义了日期的一部分—— 年和月: year and month (YYYY-MM)
time Defines a time value
定义时间值

 


Restrictions on Date Data Types
对日期数据类型的约束

Restrictions that can be used with Date data types:
可约束的日期数据类型如下所示:

  • enumeration
    列举
  • maxExclusive
    除去最大值
  • maxInclusive
    包括最大值
  • minExclusive
    除去最小值
  • minInclusive
    包括最小值
  • pattern
    式样
  • whiteSpace
    空白

评论 (1) 1 All

登陆 | 还没注册?