xml - Date operations on xsl 1.0 -


i need 3 days before , after given date defined in variable, , store each 1 of them in new individual variable in xsl 1.0. can't use extensions or third party tools.

looking trough answers in forums, found this: expanding datetime ranges in xslt 1.0 similar problem, dont understand if , how aply code.

mi date variable in standard datetime format, this:

<xsl:variable name="date" select="2014-05-13t00:00:00"/> 

and need output html similar this:

<table>   <tr>     <td>    2014-05-10     <td>   </tr>   <!---some rows pricing information --> </table> <table>   <tr>     <td>    2014-05-11     <td>   </tr>   <!---some rows pricing information --> </table> <table>   <tr>     <td>    2014-05-12     <td>   </tr>   <!---some rows pricing information --> </table> <!-- etc --> 

in rows pricing information have use each individual date perform other operations, each day must stored in variable further use.

is there way accomplish this, using xslt 1.0?

thanks in advance.

adding/subtracting number of days to/from date in pure xslt 1.0:

<xsl:stylesheet version="1.0"  xmlns:xsl="http://www.w3.org/1999/xsl/transform"> <xsl:output method="xml" version="1.0" encoding="utf-8" indent="yes"/>  <xsl:param name="givendate" select="'2014-05-13t00:00:00'"/> <xsl:param name="daysdiff" select="-3"/>  <xsl:variable name="jdn">     <xsl:call-template name="jdn">         <xsl:with-param name="date" select="$givendate" />     </xsl:call-template> </xsl:variable>  <xsl:variable name="newdate">     <xsl:call-template name="gd">         <xsl:with-param name="jdn" select="$jdn + $daysdiff" />     </xsl:call-template> </xsl:variable>   <xsl:template match="/">     <output>         <givendate><xsl:value-of select="$givendate"/></givendate>         <newdate><xsl:value-of select="$newdate"/></newdate>     </output> </xsl:template>    <xsl:template name="jdn">     <xsl:param name="date"/>     <xsl:param name="year" select="substring($date, 1, 4)"/>     <xsl:param name="month" select="substring($date, 6, 2)"/>     <xsl:param name="day" select="substring($date, 9, 2)"/>     <xsl:param name="a" select="floor((14 - $month) div 12)"/>     <xsl:param name="y" select="$year + 4800 - $a"/>     <xsl:param name="m" select="$month + 12*$a - 3"/>     <xsl:value-of select="$day + floor((153*$m + 2) div 5) + 365*$y + floor($y div 4) - floor($y div 100) + floor($y div 400) - 32045" /> </xsl:template>   <xsl:template name="gd">     <xsl:param name="jdn"/>     <xsl:param name="f" select="$jdn + 1401 + floor((floor((4 * $jdn + 274277) div 146097) * 3) div 4) - 38"/>     <xsl:param name="e" select="4*$f + 3"/>     <xsl:param name="g" select="floor(($e mod 1461) div 4)"/>     <xsl:param name="h" select="5*$g + 2"/>     <xsl:param name="d" select="floor(($h mod 153) div 5 ) + 1"/>     <xsl:param name="m" select="(floor($h div 153) + 2) mod 12 + 1"/>     <xsl:param name="y" select="floor($e div 1461) - 4716 + floor((14 - $m) div 12)"/>     <xsl:param name="mm" select="substring(100 + $m, 2)"/>     <xsl:param name="dd" select="substring(100 + $d, 2)"/>     <xsl:value-of select="concat($y, '-', $mm, '-', $dd)" /> </xsl:template>       </xsl:stylesheet> 

result:

<?xml version="1.0" encoding="utf-8"?> <output>    <givendate>2014-05-13t00:00:00</givendate>    <newdate>2014-05-10</newdate> </output> 

--
note givendate's parameter value string , such must wrapped in single quotes.


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -