home contribute faq download

FunctX XSLT Functions

functx:yearMonthDuration

Construct a yearMonthDuration from a number of years and months

Google
Webdatypic.com

Description

The functx:yearMonthDuration function constructs an xs:yearMonthDuration value from two arguments representing a number of years and a number of months. Zero can be represented either by the number 0 or the empty sequence. If both arguments are zero or the empty sequence, it returns P0M.

Arguments and Return Type

NameTypeDescription
$years xs:decimal? the number of years
$months xs:integer? the number of months
return value xs:yearMonthDuration

XSLT Function Declaration

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

  <xsl:sequence select="
    (xs:yearMonthDuration('P1M') * functx:if-empty($months,0)) +
    (xs:yearMonthDuration('P1Y') * functx:if-empty($years,0))
 "/>

</xsl:function>

Examples

XPath ExampleResults
functx:yearMonthDuration(1,6)
P1Y6M
functx:yearMonthDuration(1.5,0)
P1Y6M
functx:yearMonthDuration(1,())
P1Y
functx:yearMonthDuration(1,0)
P1Y
functx:yearMonthDuration(-1,-3)
-P1Y3M
functx:yearMonthDuration(-1,3)
-P9M
functx:yearMonthDuration(0,0)
P0M

Depends On

functx:if-emptyThe first argument if it is not blank, otherwise the second argument

See Also

functx:dayTimeDurationConstruct a dayTimeDuration from a number of days, hours, etc.

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