If you're producing a DOM as output, you need to make sure that your stylesheet produces a well-formed XML document -- for example, there must be only a single top-level element, with no text outside it -- or the DOM implementation will complain.
(SAX output is more willing to accept "xml fragments".)
