If you use the current PHP 5.2 with libxslt, libxml will add CDATA sections to your XHTML script tags. The W3C suggests the use of a CDATA section (less escaping for special chars needed), but the most browsers will not support this. Firefox supports it, if you send the mimetype
application/xhtml+xml.
To avoid the problem make your script section a html comment.
Here a sample:
<xsl:template match="script">
<script type="{@type}"><xsl:comment>
<xsl:copy-of select="text()"/>
//</xsl:comment></script>
</xsl:template>
This is a generic match for all script elements in the xml tree. But
will take care of xslt generated script elements, too.
<script type="text/javascript"><xsl:comment>
myLittleJSCall();
//</xsl:comment></script>
Here is a bug reported for libxml. But it is closed. :-(
No comments:
Post a Comment