【发布时间】:2014-08-05 09:22:20
【问题描述】:
任何人都可以帮助我如何在 XSLT 1.0 中将此时间格式转换为 hh:mm:ss 吗?
示例 1:PT1H55M0.000S ---> 01:55:00
示例 2:PT12H0M0 ---> 12:00:00
【问题讨论】:
-
为什么标题中的第二个示例与问题中的示例不同?
标签: xslt-1.0 time-format
任何人都可以帮助我如何在 XSLT 1.0 中将此时间格式转换为 hh:mm:ss 吗?
示例 1:PT1H55M0.000S ---> 01:55:00
示例 2:PT12H0M0 ---> 12:00:00
【问题讨论】:
标签: xslt-1.0 time-format
给定:
<xsl:variable name="input" select="'PT1H55M0.000S'" />
以下内容:
<output>
<xsl:value-of select="format-number(substring-before(substring-after($input, 'T'), 'H'), '00')"/>
<xsl:value-of select="format-number(substring-before(substring-after($input, 'H'), 'M'), ':00')"/>
<xsl:value-of select="format-number(substring-before(substring-after($input, 'M'), 'S'), ':00')"/>
</output>
将导致:
<output>01:55:00</output>
注意:
这假设输入包含所有三个字符:H、M 和 S;否则它要复杂得多。
【讨论】: