xsl:where-populated
Used to allow conditional content construction to be made streamable. Used to avoid outputting a wrapper element if it would have no children.
Category: instruction
Content: sequence-constructor
Permitted parent elements:
any XSLT element whose content model is
sequence-constructor; any literal result element
Element has no attributes
Saxon availability
Available in XSLT 3.0. From Saxon 9.8, available in all editions. Implemented in Saxon-PE and Saxon-EE since Saxon 9.7. Available for all platforms.
Notes on the Saxon implementation
New in XSLT 3.0, and implemented since Saxon 9.7.
Details
The contained sequence constructor is evaluated in the usual way, but any item in the result of the sequence constructor that is "deemed empty" is discarded. Examples of items that are "deemed empty" are elements with no children (even if they have attributes), and nodes and atomic values whose string value is zero-length. Document nodes are deemed empty if they have no children, as are empty maps and arrays. Text nodes containing whitespace are NOT deemed empty.
The most common use case is for the instruction to have a single child instruction, which creates an element node; the element node is discarded if it has no content.
Although the instruction was invented to help make code streamable, it can be equally handy in non-streaming applications.
Examples
The following code generates a wrapper element for a non-empty sequence,
however it is not guaranteed-streamable because it processes child
event
elements more than once:
To make this streamable, it can be rewritten using the
xsl:where-populated
instruction: