xslt 2.0格式currentdate

时间:2017-06-16 06:14:26

标签: xml datetime xslt xsd xslt-2.0

xslt 2.0

我有xsd:dateTime字段,我必须将当前日期时间格式化为

[D01]-[M01]-[Y0001] [h01]:[m01]:[s01] and using the below function

format-dateTime(current-dateTime(), '[D01]-[M01]-[Y0001] [h01]:[m01]:[s01]')

我能够将上面的输出分配给xsd:string元素而不是xsd:datetime元素。我甚至尝试类似于xsd:dateTime(format-dateTime(current-dateTime(), '[D01]-[M01]-[Y0001] [h01]:[m01]:[s01]'))进行类型转换,但没有任何作用。任何建议都会有所帮助

1 个答案:

答案 0 :(得分:1)

xs:dateTime数据类型的格式定义为YYYY-MM-DDTHH:MM:SS加上一些时区信息。 format-dateTime函数以您指定的格式返回字符串,但不返回类型xs:dateTime的值。那么你想要做的就是不可能,你可以将current-dateTime()的结果绑定到xs:dateTime类型的变量,但肯定不是你的format-dateTime(current-dateTime(), '[D01]-[M01]-[Y0001] [h01]:[m01]:[s01]')表达式的结果,因为那是一个不代表xs:dateTime值的格式的字符串。