繁体   English   中英

从XSL文件调用Javascript时出错

[英]Error while calling Javascript from XSL file

我正在尝试从XSL文件中调用javascript,但无法正常工作。

想知道:1.我的XSL文件是否有问题...(见下文)2. 在使用Javascript运行XSL之前是否需要进行任何系统配置?

IE 9.0正在用于测试该原型XSL。

这是XSL文件的内容:

<?xml version='1.0' ?>  
<xsl:stylesheet version="1.0"   
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"  
xmlns:lxslt="http://xml.apache.org/xslt"  
xmlns:result="http://www.example.com/results"  
extension-element-prefixes="result" >  

   <xsl:output method="html" indent="yes"/>  


   <lxslt:component prefix="result" functions="myParse">  
    <lxslt:script lang="javascript">  
        function myParse()   
        {  
            return "just testing....";  
        }  
    </lxslt:script>  
  </lxslt:component>  

    <xsl:template match="/">        

        <xsl:for-each select="comment/MyObject">  

            <xsl:variable name="temp" select="@objectInformation" />  

             <xsl:variable name="temp2">  
                <xsl:value-of>  
                    <script type="text/javascript">  
                        result:myParse()  
                    </script>      
                </xsl:value-of>                  
            </xsl:variable>  

            <xsl:value-of select="string($temp2)"/>  

        </xsl:for-each>  

    </xsl:template>  

</xsl:stylesheet>  

我相信在这种情况下调用函数的语法为:

<xsl:value-of select="result:myParse()" />    

或者您可以在这种情况下执行以下操作:

<xsl:variable name="temp2" select="result:myParse()" />  

并且您确定在这种情况下,名称空间不应为http://xml.apache.org/xalan吗?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM