Read XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition Online
Authors: Michael Kay
Text nodes appearing within a sequence constructor are copied to the result sequence when the sequence constructor is evaluated. However, text nodes that consist entirely of whitespace will be ignored, unless the
xml:space
attribute is used on an enclosing element to define them as significant.
Text nodes containing whitespace only are also significant if they appear as the content of an
For more information on the treatment of whitespace see Chapter 3, page 141.
Nested Sequence Constructors
Suppose the template rule actually looks like this:
The end
Here the
element contains two child elements,
and
. These are both literal result elements, so they are evaluated by copying them from the stylesheet to the result sequence.
Evaluating the
element in turn causes the sequence constructor within the
element to be evaluated. This sequence constructor contains a single literal result element, the
My first generated HTML page
.
What happens here (as far as the formal definition of the processing model is concerned) is a bottom-up process of tree construction. The sequence constructor containing the text node is evaluated to produce a result sequence containing a copy of the text node. The
element is then evaluated to produce a new
element node, which has this text node as its only child.
When the
element is evaluated, things get more interesting because it contains an XSLT instruction, namely
. This particular instruction has critical importance: when written as here, without any attributes, it means “select all the children of the current node in the source tree, and for each one, find the matching template rule in the stylesheet, and evaluate it.”
What actually happens at this point depends both on what is found in the source document, and on what other template rules are present in the stylesheet. Typically, because we are currently processing the root node of the source document tree, it will have just one child node, namely the document element (the outermost element of the source XML document). Suppose this is a