views:

1310

answers:

4

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.

+1  A: 

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.

Allain Lalonde
Or... it's unable to find the extensions you're adding. Seems to be the case. Any idea how I would find the extension?
Not matching the extension is correct.
+1  A: 

Chances are you might be using an older version of Xalan.

Try instead using the xalan:evaluate() extension.

Read more on this in this thread.

Dimitre Novatchev
Changed to using xalan:evaluate() but still giving the same error.
A: 

Dimitre would you change the

<?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">
This answer-question is not clear. Do you mean: "would you change the namespace"? Click on the 1st link in my answer and you'll see that the "xalan" prefix should be bound to the "http://xml.apache.org/xalan" namespace-uri.
Dimitre Novatchev
Updated the Question to contain more information.
A: 

Are you including the .jar files in your classpath?