Make sure your XSLT is well formed. Any unescaped <
or &
in the JavaScript code will break the XML.
You can "escape" your script by wrapping its content in <![CDATA[...]]>
like so:
<script type="application/javascript"><![CDATA[
// Put your script here
]]></script>
XML is not as forgiving as HTML. It has stricter (and simpler) parsing rules.