Construct a duration
value from an item
value.
The following construct(s) refer to this construct:
xs:duration(item $value) => duration
This is a constructor function that takes an item value as argument and
returns a value of type xs:duration
. If the argument is a literal,
then the literal must be a valid lexical form of its type.
As specified in the respective section of the W3C recommendation
XML
Schema Part 2: Datatypes, a value of type xs:duration
represents a duration of time. Its lexical form is
PnYnMnDTnh
nmns, where
nY is the number of years,
nM is the number of months,
nD is the number of days, T is the separator between
date and time, nH is the number of hours,
nM is the number of minutes and
nS is the number of seconds. Fractions of a second
are appended with a leading ".".
You can omit any of the numbers, if they equal zero. However, at least one number and its designator must be present. If you do not specify a time part, the separator character "T" must not be present. The leading "P" must always be present.
You can specify a negative duration by prepending a minus sign. If no sign is used, "+" is assumed.
$value |
item value |
---|
Generate an entry for J.S. Bach's St. Matthew passion and its duration:
<opus number="BWV244"> <title>Matthäus-Passion</title> <duration>xs:duration("PT170M52S")</duration> </opus>
These queries create further valid duration values:
xs:duration("P30Y243D")
xs:duration("PT5H")
xs:duration("-P30M")
These queries create invalid duration values:
xs:duration("P30Y243DT")
xs:duration("P5H")
xs:duration("P-30M")