xsl:element
Used to create an output element whose name might be calculated at run-time.
Category: instruction
Content: sequence-constructor
Permitted parent elements:
any XSLT element whose content model is
sequence-constructor; any literal result element
Attributes
|
| The name of the generated element. The name attribute is an attribute value template, so it may contain string expressions inside curly braces. |
|
| The namespace URI of the element. |
|
| If the value is |
|
| Attributes of the generated element can be defined by reference to named attribute sets, provided as a whitespace-separated list. They are applied in the order given: if the same attribute is generated more than once, the later value always takes precedence. |
|
| Indicates the data type of
the value of the element. The value may be a built-in type defined in XML
Schema, for example |
|
| Requests strict or lax validation of the contents of the new element node against the corresponding global element declaration in the schema. |
Saxon availability
Available in XSLT 1.0 and later versions. Available in all Saxon editions. Available for all platforms.
Notes on the Saxon implementation
When the element name is known at compile time, Saxon generates exactly the same code as for a literal result elements. Literal result elements are generally preferred in such cases because they are more readable.
Motivated by streaming, the on-empty
attribute was introduced in an
early Working Draft for XSLT 3.0, but later removed and replaced by the new xsl:on-empty, xsl:on-non-empty and xsl:where-populated
instructions. The on-empty
attribute was implemented in Saxon 9.5,
but removed in 9.7.
Details
The attributes of the generated element are defined by subsequent xsl:attribute elements, or by
reference to named attribute sets using the optional
use-attribute-sets
attribute. The content of the generated
element is whatever is generated between the <xsl:element>
and </xsl:element>
tags.
Examples
The following code creates a <FONT>
element with several
attributes:
This example is equivalent to the simpler literal result element:
<FONT SIZE="4" FACE="Courier New"> Some output text </FONT>