XSLT and XPath function reference in alphabetical order

(Excerpt from “XSLT 2.0 & XPath 2.0” by Frank Bongers, chapter 5, translated from German)

A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z

fn:minutes-from-duration

Category:

Value extraction from time values, date values and duration

Origin:

XPath 2.0

Return value:

An integer of xs:integer type; the value of the minutes component of the duration value passed on after canonisation.

Call/Arguments:

fn:minutes-from-duration($durationValue)

$durationValue:

Optional. A xs:duration duration indication from which, after conversion into the xs:dayTimeDuration type in its canonical form PnDTnHnMnS, the value of the minutes component resulting from this is extracted. If the empty sequence is passed on, the function returns an empty result sequence.

Purpose of use:

The function returns an integer which results from the minutes component of a duration value after transferring the input value which may be of any xs:duration type into the canonical form of xs:dayTimeDuration. This is achieved by removing the years and the months component from the duration value with subsequent canonisation.

If a xs:yearMonthDuration type has been passed on, it can be converted to the required xs:dayTimeDuration type – however, all of its components have the value 0, which is why the funtion consequentially returns the value 0 for the minutes component.

In order to achieve the canonical form PnDThHmMsS (with n optional, h, m, s < 60) of a xs:dayTimeDuration value passed on, all components on their own are put into canonical form. For this purpose, every single component is converted to integer values of the next greater component, whereby the residual value is maintained (example: PT130S becomes PT2M10S). For negative duration values, the returned value is accordingly negative.

Example 1 - minutes component from duration value:

fn:minutes-from-duration(

xs:dayTimeDuration("P3DT10H")

)

Results in: 0.

The duration indication is in canonical form, but has no minutes component. In this case, it is set to 0 for the output.

Example 2 - value with minutes and seconds component:

fn:minutes-from-duration(

xs:dayTimeDuration("P3DT12H32M12S")

)

Results in: 32.

Analogously to example 1 – here, apart from the days component also the components for hours and seconds are rejected.

Example 3 - duration value in non-canonical form:

fn:minutes-from-duration(

xs:dayTimeDuration("P3DT2H5M123S")

)

Results in: 7.

The duration indication is not in canonical form. Firstly, the seconds component is converted to entire minutes and remaining seconds (2M3S; 2 minutes and 3 seconds). Therefore, 2 is added to the current minutes component of 5.

Example 4 - hours from negative duration value:

fn:minutes-from-duration(

xs:dayTimeDuration("-P3DT10H")

)

Results in: 10.

The duration indication is in canonical form, but is negative. Therefore, the value of the hours component (10H) is also returned with negative leading sign.

Function definition:

XPath 1.0:

The function is not available.

XPath 2.0:

fn:minutes-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