When the source tree is created by parsing a well-formed XML document, the root node of the
source tree will automatically satisfy the normal restrictions of having no text node children and
exactly one element child. When the source tree is created in some other way, for example by using
the DOM, the usual restrictions are relaxed for the source tree as for the result tree.
3.2 Base URI
Every node also has an associated URI called its base URI, which is used for resolving attribute values
that represent relative URIs into absolute URIs. If an element or processing instruction occurs in an
external entity, the base URI of that element or processing instruction is the URI of the external entity;
otherwise, the base URI is the base URI of the document. The base URI of the document node is the
URI of the document entity. The base URI for a text node, a comment node, an attribute node or a
namespace node is the base URI of the parent of the node.
3.3 Unparsed Entities
The root node has a mapping that gives the URI for each unparsed entity declared in the document's
DTD. The URI is generated from the system identifier and public identifier specified in the entity
declaration. The XSLT processor may use the public identifier to generate a URI for the entity instead
of the URI specified in the system identifier. If the XSLT processor does not use the public identifier to
generate the URI, it must use the system identifier; if the system identifier is a relative URI, it must be
resolved into an absolute URI using the URI of the resource containing the entity declaration as the
base URI [RFC2396].
3.4 Whitespace Stripping
After the tree for a source document or stylesheet document has been constructed, but before it is
otherwise processed by XSLT, some text nodes are stripped. A text node is never stripped unless it
contains only whitespace characters. Stripping the text node removes the text node from the tree.
The stripping process takes as input a set of element names for which whitespace must be preserved.
The stripping process is applied to both stylesheets and source documents, but the set of
whitespace-preserving element names is determined differently for stylesheets and for source
documents.
A text node is preserved if any of the following apply:
The element name of the parent of the text node is in the set of whitespace-preserving element
names.
The text node contains at least one non-whitespace character. As in XML, a whitespace character
is #x20, #x9, #xD or #xA.
An ancestor element of the text node has an xml:space attribute with a value of preserve, and no
closer ancestor element has xml:space with a value of default.
Otherwise, the text node is stripped.
The xml:space attributes are not stripped from the tree.
NOTE:This implies that if an xml:space attribute is specified on a literal result element, it will
be included in the result.
For stylesheets, the set of whitespace-preserving element names consists of just xsl:text.
<!-- Category: top-level-element -->
<xsl:strip-space
e l e m e n t s = tokens/>
<!-- Category: top-level-element -->
<xsl:preserve-space
e l e m e n t s = tokens/>
For source documents, the set of whitespace-preserving element names is specified by xsl:strip-space
and xsl:preserve-space top-level elements. These elements each have an elements attribute whose value