Experimental: proposed new instruction for XSLT 4.0. It constructs an array, whose content is established using the contained sequence constructor.

Category: instruction
Content: sequence-constructor
Permitted parent elements: any XSLT element whose content model is sequence-constructor; any literal result element




The contents of the array may be given either by an expression in the select attribute, or by expanding the sequence constructor contained in the xsl:array element.



If this attribute is present with the value "yes", then the contained sequence constructor must deliver a sequence of parcels (items of type record(value, *)) and each parcel becomes one member of the constructed array. If the attribute is absent or has the value "no", then the sequence returned by the sequence constructor is converted to an array, one item per array member.

Notes on the Saxon implementation



If every member of the array is to be a singleton item, then it is simplest to use the default value composite="no". The setting composite="yes" is needed if any of the members is to be an empty sequence, or a sequence containing multiple items. (Note that when constructing an array destined for serialization as JSON, the members of the array will always contain either a single item, or be empty. Empty members translate to the JSON value null.)

With composite="yes", the array members can conveniently be constructed using the xsl:array-member instruction. However, <xsl:array-member select="1 to 3"/> can equally well be written as <xsl:sequence select="parcel(1 to 3)"/>, or as <xsl:sequence select="map{'value': 1 to 3}"/>, or <xsl:map key="'value'" select="1 to 3"/>.

A type error occurs if composite="yes" is used and there are items in the sequence that do not match the item type record(value, *) (that is, a map having an entry whose key is the string "value"). Any other entries in the map are ignored.

Links to W3C specifications

XSLT 4.0 Specification

See also