Java/XSLT: Cannot find a matching 1-argument function

Jack picture Jack · Jan 16, 2009 · Viewed 9.7k times · Source

I get the following error:

javax.servlet.ServletException: Cannot find a matching 1-argument function named {http://exslt.org/dynamic}evaluate()
at org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:841)
at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:774)

The top of my xslt file is

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
    version="1.0"   
    xmlns:dyn="http://exslt.org/dynamic" 
    extension-element-prefixes="dyn"> 

Do you know why I may be getting this error?

UPDATE

The top of my XML file now reads.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet 
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
     version="1.0"
     xmlns:xalan="http://xml.apache.org/xalan" 
     exclude-result-prefixes="xalan">

and the XML where we are failing is

<xsl:template name="test">
  <xsl:param name="param" />
  <xsl:value-of select="$param"/>
  <xsl:value-of select="xalan:evaluate($param)"/>
</xsl:template>

This codes works on one server running Tomcat 5.0 but is not working on a server running Tomcat 5.5. I imagine because the code is working on one server and not it is an environmental problem.

The XSLT is being applied to the XML via a JSP page. To me it looks like the xalan.jar file is not being used. The top of the JSP is:

<%@page import="javax.xml.transform.*"%>
<%@page import="javax.xml.transform.stream.*"%>
<%@page import="         java.security.Principal,
             java.net.URL, 
             java.net.URLConnection, 
             java.io.InputStream,
             java.io.InputStreamReader,
             java.io.Reader,
             java.io.BufferedReader,
             java.io.File,
             javax.xml.transform.*,
             javax.xml.transform.stream.*,
             javax.xml.transform.*,
             javax.xml.transform.stream.*"%>

Update The problem is that Saxon is being chosen as the XML parser. Saxon does not support this functionality. Removing the Saxon.jar fixes the problem.

Answer

Allain Lalonde picture Allain Lalonde · Jan 16, 2009

Somewhere in your XSLT you're referring to a function named "{http://exslt.org/dynamic}evaluate()" and you're not giving it the number of arguments it expects.

Or... it's unable to find the extensions you're adding.