Say you create XHTML from XML using XSLT transformation (like me from Docbook to XHTML chunks using Docbook XSLT Stylesheets ) and you want to include some Javascript in the XHTML output.

If you serve your XHTML pages with mime-type: application/xhtml+xml rather then text/html , you will have to take care of xml-relevant characters within the script code (see Javascript and XHTML for a short explanation):

<script type="text/javascript">
/* <![CDATA[ */
// content of your Javascript goes here
/* ]]> */
 
or 
 
<script type="text/javascript">
// <![CDATA[ 
 content of your Javascript goes here
//]]>
</script>

Generating this output with xslt can be a little bit tricky. My solution (probably better exist) uses a trick shown in http://www.w3.org/TR/xslt#section-XML-Output-Method:

... xslt code ...
<script type="text/javascript">
	<xsl:text disable-output-escaping="yes">
	<![CDATA[//<![]]><![CDATA[CDATA[]]>
//javascript
	<![CDATA[//]]><![CDATA[]]]]><![CDATA[>]]>
        </xsl:text>
</script>
... xslt code