xsl:element
Creates an element in the result tree with a name computed at runtime.
<xsl:element name="{$tag}">
...
</xsl:element>Use xsl:element when the element name (or its namespace) is not known at compile time and therefore cannot be written as a literal result element. Both name and namespace are attribute value templates, so they can interpolate XPath expressions in {...}.
Attributes
| Attribute | Description |
|---|---|
name |
Element name as an AVT. Required. |
namespace |
Namespace URI as an AVT. |
use-attribute-sets |
Space-separated list of attribute set names to apply. |
Examples
Creating elements named after attribute values:
<xsl:for-each select="property">
<xsl:element name="{@key}">
<xsl:value-of select="@value"/>
</xsl:element>
</xsl:for-each>With a computed namespace:
<xsl:element name="svg:rect" namespace="http://www.w3.org/2000/svg">
<xsl:attribute name="width">100</xsl:attribute>
</xsl:element>