XSLT has to handle whitespace in both the stylesheet and the source document in a reasonable and controllable way.
To deal with whitespace in the stylesheet, it employs the following rules:
The rules for whitespace in the source document are the same, with the exception that you can specify the default stripping rules with <xsl:preserve-space> and <xsl:strip-space>:
If a text node contains non-whitespace characters, it is preserved
If a text node occurs inside an element listed in <xsl:preserve-space>, it is preserved
If the nearest ancestor xml:space attribute has the value preserve, it is preserved
Otherwise it is stripped (discarded from the tree before any transformation begins)