如何在XSL中使用少于javascript的for循环工作? [英] How do I get a less than in a javascript for loop in XSL to work?

查看:59
本文介绍了如何在XSL中使用少于javascript的for循环工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用CDATA来逃避脚本,但在IE8的调试器中,我仍然在for循环条件中收到此消息:Expected')'。我假设它仍然认为;在CDATA生成的& lt; 中结束循环条件。

I am using CDATA to escape the script but in IE8's debugger I still get this message: "Expected ')'" in the for loop conditions. I am assuming it still thinks that the ; in the < generated by CDATA is ending the loop conditions.

我的XSL模板中的原始脚本:

Original script in my XSL template:

<script type="text/javascript" language="javascript">  
<![CDATA[
    function submitform(form){
        var oErrorArray = new Array();
        for (i=0;i<form.length;i++) 
        eval("oErrorArray["+i+"]=oError"+i);
        var goForm = true;
        for(i=0;i<form.length;i++) {
            oErrorArray[i].innerHTML = "";
            if(form[i].value="")){
                oErrorArray[i].innerHTML = "Error - input field is blank";
                goForm = false;
            }           
        }
        if(goForm == true) form.submit();
    }
    function resetform(form){
        form.reset();
    }
]]>
</script>

转换后生成的代码(来自IE8调试器)

<script type="text/javascript" language="javascript">
    function submitform(form){
        var oErrorArray = new Array();
        for (i=0;i&lt;form.length;i++) 
        eval("oErrorArray["+i+"]=oError"+i);
        goForm = true;
        for(i=0;i&lt;form.length;i++) {
            oErrorArray[i].innerHTML = "";
            if(form[i].value="")){
                oErrorArray[i].innerHTML = "Error - input field is blank";
                goForm = false;
            }           
        }
        if(goForm == true) form.submit();
    }
    function resetform(form){
        form.reset();
    }
</script>

IE8调试器报告错误:预期')'login.xml,第29行30 (紧接在第一个form.length之后)

Error reported by IE8 debugger: Expected ')' login.xml, line 29 character 30 (which is right after the first "form.length")

推荐答案

你需要明确禁用输出转义。

You need to disable output escaping explicitly.

http://www.w3.org/TR/xslt#disable-output-escaping

正如凯尔在评论中所说,特别需要

As Kyle note in the comments, in particular you need to

(1)删除CDATA标签和

(1) remove the CDATA tags and

(2)insert < xsl:text disable-output-escaping =yes>& lt;< / xsl:text> 您需要转义字符的位置。

(2) insert <xsl:text disable-output-escaping="yes">&lt;</xsl:text> where you need the character not to be escaped.

这篇关于如何在XSL中使用少于javascript的for循环工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆