How to Increment 1 day in Date using XSLT

坚强是说给别人听的谎言 提交于 2019-12-25 02:51:10

问题


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>

回答1:


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>

See http://xsltransform.net/pPqsHTP.



来源:https://stackoverflow.com/questions/30121009/how-to-increment-1-day-in-date-using-xslt

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!