XSLT and XPath function reference in alphabetical order
(Excerpt from “XSLT 2.0 & XPath 2.0” by Frank Bongers, chapter 5, translated from German)
Value extraction from time values, date values and duration
An integer of xs:integer type which corresponds to the value of the day component of the duration value passed on and put into canonical form.
Optional. A duration indication of xs:duration type from which, after a type conversion into the xs:dayTimeDuration type of the canonised form PnDTnHnMnS, the resulting value of the day component is extracted. If an empty sequence is passed on, the function also returns the empty sequence.
Purpose of use:
The function returns an integer which corresponds to the day component D of the duration value, provided that its value is in canonical form. All other components (hours, minutes, seconds) are rejected. If the value is not in the canonical form PnDThHmMsS (with n any number, h, m, s < 60), all components are first put into canonical form. This is being achieved, if possible, by converting each component into integer values of the next higher component while retaining the residual value (example: PT26H becomes P1D2H). For negative duration values, the returned value is accordingly negative.
Example 1 - days from duration value:
results in: 4.
In this example the returned value corresponds to the one of the day component since the value of the hour component is below 24 and the duration value is in canonical form.
Example 2 - days from duration value:
results in: 6.
First, the value has to be put in canonical form: T50H becomes 2DT2H. As a consequence, two days are added to the present value of the day component. So, the canonical form of the value is P6DT2H.
Example 3 - days from negative duration value:
results in: -3.
The returned value is negative since the input value is a negative duration. The absolute value corresponds to the one of the day component.
The function is not available.
fn:days-from-duration($arg as xs:duration?) as xs:integer?
|<< back||next >>|
Copyright © Galileo Press, Bonn 2008
Printing of the online version is permitted exclusively for private use. Otherwise this chapter from the book "XSLT 2.0 & XPath 2.0" is subject to the same provisions as those applicable for the hardcover edition: The work including all its components is protected by copyright. All rights reserved, including reproduction, translation, microfilming as well as storage and processing in electronic systems.
Galileo Press, Rheinwerkallee 4, 53227 Bonn, Germany