xsl:array

Experimental: proposed new XSLT 4.0 instruction. 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

Attributes

select?

expression

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.

composite?

boolean

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.

Saxon availability

Available in the XSLT 4.0 proposal. Requires Saxon-PE or Saxon-EE. Implemented experimentally since Saxon 11. Available for all platforms.

Notes on the Saxon implementation

Available from Saxon 11; requires syntax extensions to be enabled. Also available in earlier releases under the synonym saxon:array.

Details

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. In fact, the following constructions are all equivalent:

<xsl:array-member select="1 to 3"/><xsl:sequence select="parcel(1 to 3)"/><xsl:sequence select="map{'value': 1 to 3}"/><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.

For more information, see Creating arrays.

Links to W3C specifications

XSLT 4.0 Specification

See also

xsl:array-member