|
Generating HTML with javascript code |
|
Facts -
XSLT
|
|
Tuesday, 11 December 2007 22:31 |
|
If your XSL stylesheet produces HTML output with javascript sometimes the XSLT processor escapes the "<" and the ">" inside the javascript code. If this happens your javascript will not work properly. One way to suppress this undesired behaviour is by including the javascript code such as in
<script type="text/javascript" src="http://www.yoursite.com/yourscript.js"/>
If you still want to inline the javascript code inside the XSL sheet you can do the following:
<script type="text/javascript">
<xsl:text disable-output-escaping="yes">
<![CDATA[
/* put your unescaped javascript code here .... */
]]>
</xsl:text>
</script>
Usually the xsl:text element with the attribute disable-output-escaping is not necessary. But in some situations it can be helpful, depending on your xsl processor and postprocessing.
|