Read XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition Online
Authors: Michael Kay
A variation on this, which works equally well, is to delimit the text with empty
The effect of this is that the extra newlines and spaces now belong to whitespace-only nodes, which are stripped from the stylesheet and ignored.
Examples
Here are two simple examples using
1.
Output first-name and last-name, separated by a space:
Another way to achieve the same effect is to use the
concat()
function:
2.
Output a comma-separated list of values:
The purpose of the empty
elements is to split the comma and the following newline character into separate text nodes; this ensures that the newline character becomes part of a whitespace-only node and is therefore not copied to the output. The final
Another way to achieve this is with the separator attribute of
See Also
xsl:transform
This is a synonym of
Why is it useful to have two names for the same thing? Probably because it's the easiest way for a standards committee to keep all its members happy. More seriously, the existence of these two names is indicative of the fact that some people see XSLT as being primarily a language for transforming trees, while others see its main role as defining presentation styles. Take your pick.
Format
id? =
id
default-collation? =
uri-list
default-validation? = “preserve” | “strip”
exclude-result-prefixes? =
tokens
extension-element-prefixes? =
tokens
input-type-annotations? = “preserve” | “strip” | “unspecified”
use-when? =
expression
version =
number
xpath-default-namespace? =
uri
See Also
xsl:value-of
The
Changes in 2.0
In XSLT 2.0 the value to be output can be obtained by evaluating a contained sequence constructor as an alternative to using the
select
attribute.
A
separator
attribute has been added, allowing a sequence of values to be output separated by spaces, commas, or any other convenient string.
Format
select? = expression
separator? = { string}
disable-output-escaping? = “yes” | “no”>
Position
Attributes
Name | Value | Meaning |
select optional | XPath Expression | The value to be output. |
separator optional | Attribute value template returning a string | A string to be used to separate adjacent items in the output. |
disable-output-escaping optional, deprecated | yes or no | The value yes indicates that special characters in the output (such as < ) should be output as is, rather than using an XML escape form such as < . The default value is no . |