home contribute faq download

FunctX XSLT Functions

functx:total-years-from-duration

The total number of years in a yearMonthDuration

Google
Webxsltfunctions.com

Description

The functx:total-years-from-duration function returns the total number of years in $duration. If it is an uneven number of years, it will return a fractional part. This function is different from the built-in fn:years-from-duration function because the latter will not return a fractional part. 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-years-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('P1Y')
 "/>

</xsl:function>

Examples

XPath ExampleResults
functx:total-years-from-duration(
     xs:yearMonthDuration('P18M'))
1.5
functx:total-years-from-duration(
     xs:yearMonthDuration('P1Y'))
1
functx:total-years-from-duration(
     xs:yearMonthDuration('P1Y6M'))
1.5

See Also

fn:years-from-durationThe number of years 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-months-from-durationThe total number of months in a yearMonthDuration

History

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

Recommended Reading:

XQuery