title: Java script XSLT Error : For extension function, could not find method java.lang.String. ([ExpressionContext,] #STRING)
body: <p>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. </p>
  
  <blockquote>
    <p>For extension function, could not find
    method
    java.lang.String.FctDateDuration([ExpressionContext,]
    STRING).</p>
  </blockquote>
  
  <p>Here is how I have define my xsl.</p>
  
  <pre><code>xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:ttVB="ttVB" exclude-result
  </code></pre>
  
  <p><strong>Here is the java script calling part in xsl : -</strong></p>
  
  <pre><code>&lt;xsl:variable name="start"&gt;
        xsl:value-of select="substring(DepartureDateTime,1,10)" /&gt;
       &lt;/xsl:variable&gt;
       xsl:variable name="end"&gt;
       xsl:value-of select="substring(following-sibling::OriginDestinationInformation/DepartureDateTime,1,10)" /&gt;
       &lt;/xsl:variable&gt;
       xsl:variable name="end1"&gt;
        xsl:value-of select="substring(preceding-sibling::OriginDestinationInformation/DepartureDateTime,1,10)" /&gt;
       &lt;/xsl:variable&gt;
       xsl:variable name="dd" select="ttVB:FctDateDuration(string('2011-02-20'),string('2011-02-25'))"/&gt;
       xsl:variable name="dd1" select="ttVB:FctDateDuration(string('2011-02-20'),string('2011-02-25'))"/&gt;
       &lt;xsl:choose&gt;
        xsl:when test="$dd = 0 or $dd = 1"&gt;
         &lt;timeQualifier&gt;TA&lt;/timeQualifier&gt;
        &lt;/xsl:when&gt;
        xsl:otherwise&gt;
         timeQualifier&gt;TD&lt;/timeQualifier&gt;
        &lt;/xsl:otherwise&gt;
       &lt;/xsl:choose&gt;
  </code></pre>
  
  <p><strong>Here is my Javascript</strong> </p>
  
  <pre><code>&lt;msxsl:script language="JavaScript" implements-prefix="ttVB"&gt;
  &lt;![CDATA[
  
  function FctDateDuration(p_startDate,p_endDate){
  
  
  
      if (IsDate(p_startDate) &amp;&amp; IsDate(p_endDate)){
  
          FctDateDuration = String(calcDays(p_startDate, p_endDate)) 
  
      }else{
  
          FctDateDuration = p_startDate + p_endDate
  
      }
  
  
  
  return FctDateDuration;
  
  }
  
  
  
  function IsDate(ddate){
  
  
  
  //alert("Inside IsDate &gt;&gt; "+ddate);
  
  var dteDate;
  
  
  
  var year = ddate.substring(0, 4);
  
  var month = ddate.substring(5, 7);
  
  var day = ddate.substring(8,10);
  
  
  
  month = month-1;
  
  
  
  //alert(year);
  
  //alert(month);
  
  //alert(day);
  
  
  
  dteDate=new Date(year,month,day);
  
  
  
  
  
  return ((day==dteDate.getDate()) &amp;&amp; (month==dteDate.getMonth()) &amp;&amp; (year==dteDate.getFullYear()));
  
  
  
  
  
  }
  
  
  
  function calcDays(date1,date2){
  
    date1 = date1.split("-");
  
    date2 = date2.split("-");
  
    var sDate = new Date(date1[0]+"/"+date1[1]+"/"+date1[2]);
  
    var eDate = new Date(date2[0]+"/"+date2[1]+"/"+date2[2]);
  
    var daysApart = Math.abs(Math.round((sDate-eDate)/86400000));
  
    //document.getElementById('diffDays').lastChild.data = daysApart;
  
  
  
  //alert(daysApart);
  
  return daysApart;
  
  
  
  }
  
  
  
  
  
  ]]&gt;
  
  &lt;/msxsl:script&gt;
  </code></pre>