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

隐身守侯 提交于 2020-01-11 08:29:24

问题


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:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/450165/java-xslt-cannot-find-a-matching-1-argument-function

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!