Xml模式和日期时间 [英] Xml Schemas and Date Times

查看:147
本文介绍了Xml模式和日期时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开始一个新的项目,涉及到多个平台(Windows,Windows Mobile,Iphone,Ipad等等)尚未被发现的重xml和模式使用。这个xml平台必须能够交换来自世界各地的日期,因为我们的产品目前正在澳大利亚以及加拿大和美国实施。



日期时间通常是导致不同平台和语言之间最多问题的类型。



我应该信任内置的日期类型吗?或者我应该将每个日期分解成它的子部分,例如元素或属性为小时,分钟,秒,日,月,年,时区等。



我想了解上述每个选项的专业版和附件。 / p>

编辑:添加了2个后续问题以获得更加清晰的


  1. 如果使用纯xml日期类型,如何确保所有客户端正确地以这种格式写入日期?


  2. 我知道.net我可以使用DateTime.ToUniversalTime()做其他语言有相同的,或者是将XML写入dll的控件转换为国际时间?


感谢
Pete

解决方案

XML模式中的内置日期类型是国际标准。我不能想像你自己可以做得比那个更好。






XML Schema:W3C面向对象的XML描述,Eric van der Vlist,第16章数据类型参考指南 ,xs:dateTime:



描述



这个数据类型描述了由日期和时间。其价值空间被描述为ISO 8601第5.4章中的日期和时间的组合。其词汇空间是扩展格式[ - ] CCYY-MM-DDThh:mm:ss [Z |(+ | - )嗯:mm]。时区可以指定为Z(UTC)或(+ | - )hh:mm。未指定的时区被认为是未确定的。



示例



xs的有效值:dateTime 包括:2001-10-26T21:32:52,2001-10-26T21:32:52 + 02:00,2001-10-26T19:32:52Z,2001-10-26T19:32 :52 + 00:00,-2001-10-26T21:32:52或2001-10-26T21:32:52.12679。



以下值无效:2001-10-26(必须指定所有零件),2001-10-26T21:32(必须指定所有零件),2001-10-26T25:32:52 +02:00(小时部分(25)超出范围)或01-10-26T21:32(必须指定所有部分)。






请注意,您可以要求使用 / code>限制。


I'm beginning a new project which involves heavy xml and schema use accross multiple platforms (windows, windows mobile, Iphone, Ipad, and more which are yet to be discovered!). This xml platform has to be able to exchange date times from all over the world as our product is currently being implemented in Australia as well as in Canada and USA.

Date times are generally the one "type" that causes the most issues between different platforms and languages.

Should I trust the built in date type? or should I break down each date into it's subsections, e.g. elements or attributes for hours, mins, seconds, day, month, year, timezone etc.

I'd like to understand the pro's and con's of each options above.

EDIT: Added 2 follow up questions to get more clarity

  1. if using the plain xml date "type" how do I ensure that all clients are correctly writing the date in this format?

  2. I know that .net I can use DateTime.ToUniversalTime() do other languages have the equivalent, or is it the XML writing dll's that control the conversion to international time?

Thanks Pete

解决方案

The "built in" date types in XML schema are an International standard. I can't imagine how you could do better than that on your own.


From XML Schema: The W3C's Object-Oriented Descriptions for XML by Eric van der Vlist, Chapter 16, "Datatype Reference Guide", "xs:dateTime":

Description

This datatype describes instants(sic) identified by the combination of a date and a time. Its value space is described as a "combination of date and time of day" in Chapter 5.4 of ISO 8601. Its lexical space is the extended format "[-]CCYY-MM-DDThh:mm:ss[Z|(+|-)hh:mm]". The timezone may be specified as "Z" (UTC) or "(+|-)hh:mm." Timezones that are not specified are considered "undetermined."

Example

Valid values for xs:dateTime include: "2001-10-26T21:32:52", "2001-10-26T21:32:52+02:00", "2001-10-26T19:32:52Z", "2001-10-26T19:32:52+00:00", "-2001-10-26T21:32:52", or "2001-10-26T21:32:52.12679".

The following values would be invalid: "2001-10-26" (all the parts must be specified), "2001-10-26T21:32" (all the parts must be specified), "2001-10-26T25:32:52+02:00" (the hours part (25) is out of range), or "01-10-26T21:32" (all the parts must be specified).


Note that you can require that a timezone be specified by restricting the value with a pattern restriction.

这篇关于Xml模式和日期时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆