如何使用 XSLT 在日期中增加 1 天 [英] How to Increment 1 day in Date using XSLT

查看:33
本文介绍了如何使用 XSLT 在日期中增加 1 天的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个场景,我们需要在现有日期中增加 1 天.就像在 2015-05-06 我想增加 1 天并将其值映射到 2015-05-07.我如何使用 XSLT 实现这一点.因此,还应处理所有日期限制.就像如果天是 31 则以月为单位递增.

I have a scenario in which we need to increment 1 day in existing date. Like In <subscriptionDate>2015-05-06</subscriptionDate> I want to increase 1 day and map its value to <terminationDate>2015-05-07</terminationDate>. How can I achieve this using XSLT. So, all date constraints should also be handled. like if day is 31 then increment in month.

<Subscription code="12345678R1">
      <userAccount>40000005b</userAccount>
      <offerTemplate>Test</offerTemplate>
      <subscriptionDate>2015-05-06</subscriptionDate>
      <terminationDate></terminationDate>
</Subscription>

推荐答案

假设 XSLT 2.0 您可以为日期添加持续时间,例如

Assuming XSLT 2.0 you can add a duration to an date e.g.

<xsl:template match="terminationDate">
  <xsl:copy>
    <xsl:value-of select="xs:date(preceding-sibling::subscriptionDate) + xs:dayTimeDuration('P1D')"/>
  </xsl:copy>
</xsl:template>

请参阅 http://xsltransform.net/pPqsHTP.

这篇关于如何使用 XSLT 在日期中增加 1 天的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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