gpt4 book ai didi

xml - 如何使用 XSLT 在日期中增加 1 天

转载 作者:行者123 更新时间:2023-12-04 00:27:16 24 4
gpt4 key购买 nike

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

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

最佳答案

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

<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 .

关于xml - 如何使用 XSLT 在日期中增加 1 天,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30121009/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com