XSL解析缩短了脚本标记,导致IE中出现问题 [英] XSL parsing is shortening script tag causing issues in IE
问题描述
我有一个C#应用程序,它通过使用xsl文件转换xml文件来生成html文档。在我的xsl模板中,我引用了一个外部javascript文件,如下所示:
I have a C# application that generates an html document from transforming an xml file with an xsl file. In my xsl template I reference an external javascript file like this:
<script language="javascript" type="text/javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js" ></script>
转换后上一行转换为:
<script language="javascript" type="text/javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js" />
对于Firefox和Chrome,这不是问题,但IE会抛出找不到对象错误而不会工作。有任何建议让IE喜欢这种语法吗?或者我在xsl(或C#XslCompiledTransform类)中需要做些什么来保留语法?
For Firefox and Chrome this is no problem however IE throws an 'object not found' error and does not work. Any suggestions for getting IE to like this syntax? Or is there something I need to do in my xsl (or the C# XslCompiledTransform class) to preserve the syntax?
解决方案:通过放置<![CDATA [<! - 一些评论 - >脚本标记之间的]]>
解析器不会尝试缩短结束标记。
Solution: By placing <![CDATA[ <!-- Some Comment --> ]]>
between the script tags the parser doesn't attempt to shorten the ending tag.
推荐答案
尝试在其中放入一个空的CDATA部分。这应该强制解析器不要弄乱你的脚本标签。
Try putting an empty CDATA section inside. This should force the parser to not mess with your script tags.
<script language="javascript" type="text/javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js" ><![CDATA[ ]]></script>
这篇关于XSL解析缩短了脚本标记,导致IE中出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!