xml - How to increment date and time in XSLT 2.0 -
i have following date scenario, in want increment in date, date format of following: 2015-05-03t00:00:00z. want increment in date of 1 day. if reaches 31 month should updated. saw existing question solution not working on scenario.
xml:
<?xml version="1.0" encoding="utf-8"?> <rootelement> <testdate>2015-05-03t00:00:00z</testdate> </rootelement>
xslt:
<?xml version="1.0" encoding="utf-8" ?> <xsl:transform xmlns:xsl="http://www.w3.org/1999/xsl/transform" version="2.0"> <xsl:template match="rootelement"> <transformdate> <xsl:value-of select="substring(testdate,1,10)" /> </transformdate> </xsl:template> </xsl:transform>
result:
<?xml version="1.0" encoding="utf-8"?> <transformdate>2015-05-03</transformdate>
expectedresult:
<?xml version="1.0" encoding="utf-8"?> <transformdate>2015-05-04t00:00:00z</transformdate>
try stylesheet:
<?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform" xmlns:xs="http://www.w3.org/2001/xmlschema"> <xsl:strip-space elements="*"/> <xsl:output indent="yes" omit-xml-declaration="yes"/> <xsl:template match="rootelement"> <xsl:element name="transformdate"> <xsl:value-of select="xs:datetime(testdate) + xs:daytimeduration('p1d')"/> </xsl:element> </xsl:template> </xsl:stylesheet>
Comments
Post a Comment