title: Saxon throws 'top-level text node' exception for XSLT, but XML seems well-formed to me
body: <p>I'm running Cocoon with Apache Tomcat 7.0.42, on Mac OSX. I'm continually getting a very strange error from Saxon. It says I have a top-level text-node in my XML. First off, I'm not sure if they mean my output xml or my xsl xml. Secondly, I believe neither has a top-level text node.</p>
  
  <p>Here is the error message from the stack trace:</p>
  
  <blockquote>
    <p>net.sf.saxon.trans.XPathException: When 'standalone' or 'doctype-system' is specified, the document must be well-formed; but this document contains a top-level text node
        net.sf.saxon.serialize.XMLEmitter.characters(XMLEmitter.java:574)
        net.sf.saxon.event.ReceivingContentHandler.flush(ReceivingContentHandler.java:543)</p>
  </blockquote>
  
  <p>&lt;...long stack trace...></p>
  
  <blockquote>
    <p>org.apache.cocoon.servletservice.DispatcherServlet.service(DispatcherServlet.java:106)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
        org.apache.cocoon.servlet.multipart.MultipartFilter.doFilter(MultipartFilter.java:131)</p>
  </blockquote>
  
  <p>Here is my departments_list.xsl, which imports common.xsl:</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;xsl:stylesheet version="2.0"
      xmlns="http://www.w3.org/1999/xhtml"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;
  
      &lt;xsl:import href="common.xsl" /&gt;
  
  
      &lt;xsl:output method="html" encoding="utf-8" omit-xml-declaration="yes" indent="yes" /&gt;
  
      &lt;xsl:template match="/"&gt;
          &lt;html lang="en"&gt;
              &lt;body&gt;
                  &lt;xsl:call-template name="header" /&gt;
                  &lt;xsl:call-template name="footer" /&gt;
              &lt;/body&gt;
          &lt;/html&gt;
      &lt;/xsl:template&gt;
  
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>Here is my common.xsl:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;xsl:stylesheet version="2.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns="http://www.w3.org/1999/xhtml"&gt;
  
  &lt;xsl:template name="header"&gt;
      &lt;meta http-equiv="Content-Type" content="text/html;charset=utf-8" /&gt;
      &lt;head&gt;
          &lt;title&gt; 
          &lt;!-- static for now. Can use parameters though. --&gt;
      Harvard University FAS Course Catalog
          &lt;/title&gt;
          &lt;xsl:call-template name="css" /&gt;
          &lt;xsl:call-template name="js" /&gt;
      &lt;/head&gt;
  &lt;/xsl:template&gt;
  
  &lt;xsl:template name="footer"&gt;
      &lt;div id="footer"&gt;
          &lt;hr /&gt;
          &lt;ul&gt;
              &lt;li&gt;Web Development with XML&lt;/li&gt;
              &lt;li&gt;Bret Fontecchio&lt;/li&gt;
              &lt;li&gt;Fall 2013&lt;/li&gt;
          &lt;/ul&gt;
      &lt;/div&gt;
  &lt;/xsl:template&gt;
  
  &lt;xsl:template name="css"&gt;
      &lt;style type="text/css"&gt;
          &lt;!-- CSS Rules --&gt;
      &lt;/style&gt;
  &lt;/xsl:template&gt;
  
  &lt;xsl:template name="js"&gt;
      &lt;!-- use this template to add js
      &lt;script type="text/javascript" src="foobar.js"&gt;&lt;/script&gt;
  --&gt;
  &lt;/xsl:template&gt;
  
  &lt;/xsl:stylesheet&gt;
  </code></pre>