Creates an element with the specified name in the output.
Syntax
<xsl:element
name="element-name" >
</xsl:element>
Attributes
name
Name of the element to create.
Element Information
Number of occurrences | Unlimited |
Parent elements | xsl:copy, xsl:element, xsl:for-each, xsl:if, xsl:otherwise, xsl:template, xsl:when, output elements |
Child elements | xsl:apply-templates, xsl:attribute, xsl:choose, xsl:comment, xsl:copy, xsl:element, xsl:eval, xsl:for-each, xsl:if, xsl:pi, xsl:value-of, output elements |
Requires closing tag | Yes. XSL is an XML grammar and, like all XML grammars, all tags must have closing tags to satisfy the definition of well-formed. |
Remarks
This element provides an escaping mechanism for creating elements with namespace clashes, such as xsl itself.
Examples
This example shows a template that generates this element in the output.
<xsl:template match="cost" xml:space="preserve">
The xsl:element is necessary because XSL elements cannot be used as output elements.
<xsl:template match="item">
<xsl:element name="xsl:template">
<xsl:attribute name="match">cost</xsl:attribute >
<xsl:attribute name="xml:space">preserve</xsl:attribute>
<xsl:apply-templates />
</xsl:element>
</xsl:template>
See Also