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. |
|
|
|
|
|
|
|
|
Attributes of the generated element can be defined by reference to named attribute sets, provided as a white-space-separated list. They are applied in the order given: if the same attribute is generated more than once, the later value always takes precedence. |
|
|
Added in XSLT 2.0. Indicates the data type of
the value of the element. The value may be a built-in type defined in XML
Schema, for example |
|
|
|
|
|
Added in XSLT 3.0, motivated by streaming.
Expression which defines an alternative result in the case where the element
would otherwise be empty. The most likely value is |
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
Example 1
The following code creates a <FONT>
element with several
attributes:
Example 2
The following is an example using the on-empty="()"
attribute
new in XSLT 3.0, motivated by streaming:
This has the effect that if there are no authors, no
<authors>
element will be written. Achieving this
within the constraints of streaming can be difficult. But of course the
feature is also a convenient short-cut quite independently of streaming.