Subject: Re: [xsl] difference between an integer and current-dateTime() From: "Martin Honnen martin.honnen@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Mon, 30 Mar 2020 11:57:13 -0000 |
B xmlns:xs="http://www.w3.org/2001/XMLSchema"On Mon, Mar 30, 2020 at 12:23 PM Martin Honnen martin.honnen@xxxxxx <mailto:martin.honnen@xxxxxx> <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx <mailto:xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>> wrote:
Am 30.03.2020 um 08:49 schrieb Mukul Gandhi gandhi.mukul@xxxxxxxxx <mailto:gandhi.mukul@xxxxxxxxx>:
Here you have used the wrong prefix "xs" again, instead you want B B B <xsl:sequence select="$totalSecs"/> no?
The following finally works for me,
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
B B B B B B B B B B B B
as="xs:dateTime"/>B B B B B B B B B B B B B xmlns:fn0="http://fns0" B B B B B B B B B B B B B exclude-result-prefixes="xs fn0" B B B B B B B B B B B B B version="3.0">
B B <xsl:output method="text"/>
B B <xsl:param name="secsSinceEpoch" as="xs:integer"/>
B B <xsl:template match="/"> B B B B <xsl:variable name="epochDateTime" select="xs:dateTime('1970-01-01T00:00:00Z') +
B B B B B xs:dayTimeDuration('PT' || $secsSinceEpoch || 'S')"
B B B B B B B B B B B B B B B B B B B B B
B B B B <xsl:variable name="diffDTduration" select="current-dateTime()-
select="fn0:minsFromdiffDTduration($diffDTduration)"/>$epochDateTime" as="xs:dayTimeDuration"/> B B B B <xsl:value-of
B B </xsl:template>*
B B <xsl:function name="fn0:minsFromdiffDTduration" as="xs:decimal"> B B B B <xsl:param name="diffDTduration" as="xs:dayTimeDuration"/>
B B B B <xsl:variable name="yrsDuration" select="years-from-duration($diffDTduration)"/> B B B B <xsl:variable name="mnthsDuration" select="months-from-duration($diffDTduration)"/> B B B B <xsl:variable name="daysDuration" select="days-from-duration($diffDTduration)"/> B B B B <xsl:variable name="hrsDuration" select="hours-from-duration($diffDTduration)"/> B B B B <xsl:variable name="mnsDuration" select="minutes-from-duration($diffDTduration)"/> B B B B <xsl:variable name="secsDuration" select="seconds-from-duration($diffDTduration)"/>
B B B B <xsl:variable name="totalSecs" select="$yrsDuration * 365 * 24
60 + $mnthsDuration * 30 * 24 * 60 +
$daysDuration * 24 * 60 + $hrsDuration * 60 + $mnsDuration +
$secsDuration div 60" /> B B B B <xsl:sequence select="$totalSecs"/>
B B </xsl:function>
</xsl:stylesheet>
I don't think you need that function, the date, dateTime and duration arithmetics in XPath 2 and later will give you the result with $diffDTduration div xs:dayTimeDuration('PT1M')
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] difference between an int, Mukul Gandhi gandhi. | Thread | Re: [xsl] difference between an int, Michael Kay mike@xxx |
Re: [xsl] difference between an int, Mukul Gandhi gandhi. | Date | Re: [xsl] difference between an int, Michael Kay mike@xxx |
Month |