SAXONICA

Saxon Documentation
Full Contents
About Saxon
Changes in this Release
Conditions of Use
Using XSLT 2.0
Using XQuery
Handling Source Documents
XML Schema Processing
XPath API for Java
Saxon on .NET
Extensibility
Saxon Extensions
Sample Saxon Applications
The Saxon SQL Extension
XSLT Elements
| Introduction
| xsl:analyze-string
| xsl:apply-imports
| xsl:apply-templates
| xsl:attribute
| xsl:attribute-set
| xsl:call-template
| xsl:character-map
| xsl:choose
| xsl:comment
| xsl:copy
| xsl:copy-of
| xsl:decimal-format
| xsl:document
» | xsl:element
| xsl:fallback
| xsl:for-each
| xsl:for-each-group
| xsl:function
| xsl:if
| xsl:include
| xsl:import
| xsl:import-schema
| xsl:key
| xsl:matching-substring
| xsl:message
| xsl:namespace
| xsl:namespace-alias
| xsl:next-match
| xsl:non-matching-substring
| xsl:number
| xsl:otherwise
| xsl:output
| xsl:output-character
| xsl:param
| xsl:perform-sort
| xsl:preserve-space
| xsl:processing-instruction
| xsl:result-document
| xsl:sequence
| xsl:sort
| xsl:strip-space
| xsl:stylesheet
| xsl:template
| xsl:text
| xsl:value-of
| xsl:variable
| xsl:when
| xsl:with-param
| Literal Result Elements
| XSLT Patterns
XPath 2.0 Expression Syntax
Function Library
Standards Conformance

# xsl:element

The `xsl:element` instruction is used to create an output element whose name might be calculated at run-time.

The element has a mandatory attribute, `name`, which is the name of the generated element. The name attribute is an attribute value template, so it may contain string expressions inside curly braces.

The attributes of the generated element are defined by subsequent `xsl:attribute` elements. The content of the generated element is whatever is generated between the `<xsl:element>` and `</xsl:element>` tags.

Additionally, attributes of the generated element can be defined by reference to a named attribute set. The optional use-attribute-sets attribute contains a white-space-separated list of attribute set names. They are applied in the order given: if the same attribute is generated more than once, the later value always takes precedence.

For example, the following code creates a <FONT> element with several attributes:

    <xsl:element name="FONT">
        <xsl:attribute name="SIZE">4</xsl:attribute>
        <xsl:attribute name="FACE">Courier New</xsl:attribute>
    Some output text
    </xsl:element>

A new attribute `type-annotation` is available in XSLT 2.0. This indicates the data type of the value of the element. In Saxon 7.3, the value must be a built-in type defined in XML Schema, for example `xs:integer` or `xs:date`. Type annotations are only accessible if the attribute is added to a temporary tree that specifies `type-information="preserve"`. The value given to the element must be a string that conforms to the rules for the data type, as defined in XML Schema. In particular this means that the element must not have any element children.

Next