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| Name | Type | Description |
$years |
xs:decimal? |
the number of years |
$months |
xs:integer? |
the number of months |
| return value |
xs:yearMonthDuration |
XSLT Function Declaration| See XQuery definition. | | XSLT 2.0 Syntax: |
|---|
<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| XSLT Example | Results |
|---|
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-empty | The first argument if it is not blank, otherwise the second argument |
See AlsoHistory |
|