Skip to content Skip to sidebar Skip to footer

Java Script Xslt Error : For Extension Function, Could Not Find Method Java.lang.string. ([expressioncontext,] #string)

HI, I am using Xalan to parse my xsl file. The xsl is working properly in the vb.net parsers. But Xalan gives error for that xsl. For extension function, could not find method

Solution 1:

Well extension functions are hardly portable, not even the way they are defined is portable. With .NET you can use the msxsl:script element to define extension functions but don't expect Xalan to support that. According to http://xml.apache.org/xalan-j/extensions.html#ex-basic Xalan Java supports a xalan:script element if you put bsf.jar and js.jar on the classpath.

Solution 2:

You should mark the java script section as CDATA.

See below

<xalan:componentprefix="ttVB"functions="FctDateDuration"><xalan:scriptlang="javascript">

<![CDATA[
function FctDateDuration(p_startDate,p_endDate){
    //alert("inside");
.
.

}]]>
</xalan:script>

Solution 3:

I was able to parse the xsl properly. Thanks Martin for the help you gave. I would like to put here the changes I made. So It'll help to others.

I had to use bsf.jar and js.jar. Since bsf jar is not shipped with xalan. bsf-2.4.0 Also I would like to tell that I had to use the xalan jars separately. Java 1.5 inbuilt xalan gave me errors.

I changed the xsl decleration sl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xalan="http://xml.apache.org/xalan" xmlns:ttVB="ext1" extension-element-prefixes="ttVB" exclude-result-prefixes="ttVB" version="1.0"

And Javascript declaration according to the http://xml.apache.org/xalan-j/extensions.html#ex-basic

xalan:component prefix="ttVB" functions="FctDateDuration">

xalan:script lang="javascript">

Post a Comment for "Java Script Xslt Error : For Extension Function, Could Not Find Method Java.lang.string. ([expressioncontext,] #string)"