简体   繁体   中英

Error while calling Javascript from XSL file

Am trying to call javascript from within my XSL file, but it is not working..

Wanted to know: 1. Is there any problem with my XSL file... (see below) 2. Is there any system configuration to be done before running XSL with Javascript?

IE 9.0 is being used for testing of this prototype XSL.

Here is the content of XSL file :

<?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>  

I believe the syntax for calling your function in this case would be:

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

Or you could just do this in this case:

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

And are you sure that the namespace in this case shouldn't be http://xml.apache.org/xalan ?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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