SAXONICA

Saxon Documentation
Full Contents
About Saxon
Changes in this Release
Notices
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:value-of

The `xsl:value-of` element evaluates an expression as a string, and outputs its value to the current result tree.

The full syntax of expressions is outlined in XPath Expression Syntax.

The `select` attribute identifes the expression. If this is not specified, the value to be output is obtained by evaluating the sequence constructor contained within the `xsl:value-of` element.

The optional `disable-output-escaping` attribute may be set to "yes" or "no"; the default is "no". If set to "yes", special characters such as "<" and "&" will be output as themselves, not as entities. Be aware that in general this can produce non-well-formed XML or HTML. It is useful, however, when generating things such as ASP or JSP pages. Escaping may not be disabled when writing to a result tree fragment.

If the `select` expression evaluates to a sequence containing more than one item, the result depends on whether a `separator` attribute is present. If the `separator` is absent when running in 1.0 mode, then only the first item is considered. When running in 2.0 mode, all the items are output. The separator defaults to a single space if the `select` attribute is used, or to a zero-length string if a sequence constructor is used. The `separator` attribute may be specified as an attribute value template.

Here are some examples of expressions that can be used in the select attribute:

Expression | value
TITLE | The character content of the first child TITLE element if there is one
@NAME | The value of the NAME attribute of the current element if there is one
. | The expanded character content of the current element
../TITLE | The expanded character content of the first TITLE child of the parent element, if there is one
ancestor::SECTION/TITLE | The expanded character content of the first TITLE child of the enclosing SECTION element, if there is one
ancestor::*/TITLE | The expanded character content of the first TITLE child of the nearest enclosing element that has a child element named TITLE
PERSON[@ID] | The content of the first child PERSON element having an ID attribute, if there is one
*[last()]/@ID | The value of the ID attribute of the last child element of any type, if there are any
.//TITLE | The content of the first descendant TITLE element if there is one
sum(*/@SALES) | The numeric total of the values of the SALES attributes of all child elements that have a SALES attribute

Next