home contribute faq download

FunctX XSLT Functions

functx:total-months-from-duration

The total number of months in a yearMonthDuration

Google
Webdatypic.com

Description

The functx:total-months-from-duration function returns the total number of months in $duration. This function is different from the built-in fn:months-from-duration function because the latter will normalize the value and only give you the remainder number of months between 1 and 12. For example, fn:months-from-duration(xs:yearMonthDuration("P18M")) will return 6, while functx:total-months-from-duration(xs:yearMonthDuration("P18M")) will return 18. If $duration is the empty sequence, the empty sequence is returned.

Arguments and Return Type

NameTypeDescription
$duration xs:yearMonthDuration? the duration
return value xs:decimal?

XSLT Function Declaration

See XQuery definition.
<xsl:function name="functx:total-months-from-duration" as="xs:decimal?"
              xmlns:functx="http://www.functx.com">
  <xsl:param name="duration" as="xs:yearMonthDuration?"/>

  <xsl:sequence select="
   $duration div xs:yearMonthDuration('P1M')
 "/>

</xsl:function>

Examples

XPath ExampleResults
functx:total-months-from-duration(
     xs:yearMonthDuration('P18M'))
18
functx:total-months-from-duration(
     xs:yearMonthDuration('P1Y'))
12
functx:total-months-from-duration(
     xs:yearMonthDuration('P1Y6M'))
18

See Also

fn:months-from-durationThe number of months in a duration
functx:total-seconds-from-durationThe total number of seconds in a dayTimeDuration
functx:total-minutes-from-durationThe total number of minutes in a dayTimeDuration
functx:total-hours-from-durationThe total number of hours in a dayTimeDuration
functx:total-days-from-durationThe total number of days in a dayTimeDuration
functx:total-years-from-durationThe total number of years in a yearMonthDuration

History

Published OnLast UpdatedContributor(s)
2006-06-272007-02-26Priscilla Walmsley, Datypic, pwalmsley@datypic.com, https://www.datypic.com
Datypic XSLT Services

Recommended Reading:

XQuery