2016-09-29 18 views

回答

1

假设你有值“PT11H22M”作为一个字符串:

<xsl:variable name="s" as="xs:string" select="'PT11H22M'"/> 

假设你的时间总是小于24小时,你可以将字符串转换“PT11 H22M”使用

<xsl:variable name="d" as="xs"dayTimeDuration" 
       select="xs:dayTimeDuration($s)"/> 

的持续时间,您就可以使用

<xsl:variable name="t" as="xs:time" select="xs:time('00:00:00') + $d"/> 

将它转换为一个时间的,一天,然后就可以格式化这是字符串‘使用

<xsl:variable name="out" as="xs:string" 
       select="format-time($t, '[H01].[m01]')"/> 
11.22’

或者,您可以使用fn:hours-from-durationfn:minutes-from-duration提取持续时间的小时和分钟组件,然后使用fn:format-number将它们格式化为数字。