Read XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition Online
Authors: Michael Kay
Usage
Standalone XPath 2.0 does not provide any facilities for formatting the date and time for display. You can do this in XSLT 2.0 using the functions
format-date()
,
format-dateTime()
, and
format-time()
.
See Also
adjust-date/time-to-timezone()
functions described on page 738
format-date/time/dateTime()
on page 781
X-from-date/time/dateTime()
functions described in their alphabetical position in this chapter, where X is one of
year
,
month
,
day
,
hours
,
minutes
,
seconds
, or
timezone
.
current-group
This function is available in XSLT only
.
The
current-group()
function returns the set of items making up the group that is currently being processed using the
Signature
There are no arguments.
Type | Meaning | |
Result | item()* | A sequence of items, specifically the sequence that is being processed in the current iteration of an |
Effect
When the stylesheet starts executing, there is no current group; the
current-group()
function then returns an empty sequence.
The
current-group()
function returns the sequence of items that participate in that group.
The
current-group()
function does not need to be called textually within the
The
current-group()
function can also be called while evaluating the sort key in an
current-group()
refers to the group whose sort key is being calculated. For example, to sort groups in order of decreasing size, write
On entry to a stylesheet function, the current group is an empty sequence.
Usage and Examples
See
See Also
current-grouping-key()
in the following section
current-grouping-key
This function is available in XSLT only
.
The
current-grouping-key()
function returns the value of the grouping key that defines the group currently being processed using the
group-by
or
group-adjacent
attribute. When grouping is done using patterns, there is no current grouping key.
Signature
There are no arguments.
Type | Meaning | |
Result | xs:anyAtomicType? | This is the value of the group-by or group-adjacent expression that is shared by all the items in the current group. The return type indicates that the grouping key can be of any atomic type; for example , xs:string , xs:decimal , or xs:date . When there is no current group, the function returns an empty sequence . |
Effect
When the stylesheet starts executing, there is no current grouping key; the
current-grouping-key()
function then returns an empty sequence.
The
group-by
or
group-adjacent
attributes, then while each group is being processed, the
current-grouping-key()
function returns the grouping key value that characterizes that group.
If the grouping criteria are defined using the
group-starting-with
or
group-ending-with
attributes of
The
current-grouping-key()
function does not need to be called textually within the
The
current-grouping-key()
function can also be called while evaluating the sort key in an
current-grouping-key()
refers to the group whose sort key is being calculated. For example, to sort groups in descending order of their grouping key, write
On entry to a stylesheet function, the current grouping key is an empty sequence.
Usage and Examples
The following example groups a set of books by the name of the author. For each author, a section heading is displayed giving the name of the author, followed by a list of the books written by this author. The authors are sorted by name. A book that has several authors will be listed more than once.
See Also
current-group()
on page 739
current-time
See
current-date()
on page 738
data
The
data()
function returns the atomized value of a sequence. This means that any nodes in the input sequence are replaced by their typed values.
Signature
Argument | Type | Meaning |
sequence | item()* | The input sequence |
Result | xs:anyAtomicType* | A sequence based on the input sequence, in which all nodes have been replaced by their typed values |
Effect
Atomization is a process that is invoked implicitly when a sequence containing nodes is used in a context where atomic values are expected. For example, if you write
@a+42
, the attribute node represented by the expression
@a
is atomized to obtain a number, which is then added to 42. The
data()
function invokes atomization explicitly, and is used either in a context where implicit atomization does not occur (for example, the argument to the
count()
function is not atomized), or in cases where you want to make it clear to the reader what is going on.
Atomization applies the following process to each item in the input sequence. The results are concatenated together retaining the original sequence order:
The typed value of a node depends on its type annotation. In the absence of a schema, or when the type annotation is
xs:untypedAtomic
or
xs:untyped
, the typed value is the same as the string value, but the resulting atomic value remains an
xs:untypedAtomic
value rather than a string, which allows it to be used in contexts (for example, as an operand of
+
) where a string would not be allowed.