<?xml version="1.0" encoding="iso-8859-1"?>
<?xml-stylesheet href="../make-menu.xsl" type="text/xsl"?><html>
   <head>
      <this-is section="sourcedocs" page="whitespace" subpage=""/>
      <!--
           Generated at 2010-10-29T18:20:48.427+01:00--><title>Saxonica: XSLT and XQuery Processing: Whitespace Stripping in Source Documents</title>
      <meta name="coverage" content="Worldwide"/>
      <meta name="copyright" content="Copyright Saxonica Ltd"/>
      <meta name="title"
            content="Saxonica: XSLT and XQuery Processing: Whitespace Stripping in Source Documents"/>
      <meta name="robots" content="noindex,nofollow"/>
      <link rel="stylesheet" href="../saxondocs.css" type="text/css"/>
   </head>
   <body class="main">
      <h1>Whitespace Stripping in Source Documents</h1>
      <p>A number of factors combine to determine whether whitespace-only text nodes in the source document
are visible to the user-written XSLT or XQuery code.</p>
      <p>By default, if there is a DTD or schema, then <i>ignorable whitespace</i> is stripped from any source
document loaded from a <code>StreamSource</code> or <code>SAXSource</code>. Ignorable whitespace is defined
as the whitespace that appears separating the child elements in element declared to have element-only content.
This whitespace is removed regardless of any <code>xml:space</code> attributes in the source document.</p>
      <p>It is possible to change this default behavior in several ways.</p>
      <ul>
         <li content="para">
            <p>From the Transform or Query command line, options are available: <code>-strip:all</code> strips all whitespace text nodes,
<code>-strip:none</code> strips no whitespace text nodes, and <code>-strip:ignorable</code> strips ignorable whitespace text nodes only
 (this is the default).</p>
         </li>
         <li content="para">
            <p>If the <code>-p</code> option is used on the command line, then query parameters are recognized in the URI passed to 
the <code>document()</code> or <code>doc()</code> function. The parameter <code>strip-space=yes</code> strips
all whitespace text nodes, <code>strip-space=no</code> strips
no whitespace text nodes, and <code>strip-space=ignorable</code> strips
ignorable whitespace text nodes only. This overrides anything specified on the command line.</p>
         </li>
         <li content="para">
            <p>Options corresponding to the above can also be set on the <code>TransformerFactory</code> object or on the
<a class="bodylink" href="../javadoc/net/sf/saxon/Configuration.html"><code>Configuration</code></a>. These settings are global.</p>
         </li>
      </ul>
      <p>Whitespace stripping that is specified in any of the above ways does not occur only if the source document is 
parsed under Saxon's control: that is, if it supplied as a JAXP <code>StreamSource</code> or <code>SAXSource</code>. It also applies where
      the input is supplied in the form of a tree (for example, a DOM). In this case Saxon wraps the supplied tree in a virtual tree that provides a view of
      the original tree with whitespace text nodes omitted.</p>
      <p>This whitespace stripping is additional (and prior) to any stripping carried out as a result of the
<code>xsl:strip-space</code> declaration in the stylesheet.</p>
      <table width="100%">
         <tr>
            <td>
               <p align="right"><a class="nav" href="streaming.xml">Next</a></p>
            </td>
         </tr>
      </table>
   </body>
</html>