Project

Profile

Help

Used to work but now "Cannot find a matching 0-argument function"

Added by Chris Tomlinson about 9 years ago

I'm stumped and would very much appreciate another pair of eyeballs taking a look. I'm using saxonpe-9.4.0.9 with a license in an XSLT in XQuery in eXist-db 2.2.RC2. It has worked but now is not, and I haven't changed the java extension. I'm getting the following error which appears to indicate that saxonpe is being used and that apparently the extension class is found but the toUnicode() function is not found:

======== 2015-01-20 15:56:00,139 [http-nio-51173-exec-1] WARN (Transform.java [fatalError]:816) - XSL transform reports fatal error: Cannot find a matching 0-argument function named {java:org.tbrc.saxon.Convert}toUnicode(). The namespace URI and local name are recognized, but the number of arguments is wrong ; Line#: -1; Column#: -1 net.sf.saxon.trans.XPathException: Cannot find a matching 0-argument function named {java:org.tbrc.saxon.Convert}toUnicode(). The namespace URI and local name are recognized, but the number of arguments is wrong at net.sf.saxon.expr.ErrorExpression.evaluateItem(ErrorExpression.java:66) at net.sf.saxon.expr.ErrorExpression.iterate(ErrorExpression.java:80) at net.sf.saxon.expr.Atomizer.iterate(Atomizer.java:230) at net.sf.saxon.expr.FirstItemExpression.evaluateItem(FirstItemExpression.java:55) at net.sf.saxon.expr.AtomicSequenceConverter.evaluateItem(AtomicSequenceConverter.java:325) at net.sf.saxon.expr.Expression.evaluateAsString(Expression.java:505) at net.sf.saxon.expr.instruct.SimpleNodeConstructor.processLeavingTail(SimpleNodeConstructor.java:194) at net.sf.saxon.expr.instruct.ValueOf.processLeavingTail(ValueOf.java:245) at net.sf.saxon.expr.instruct.Block.processLeavingTail(Block.java:615) . . .

The XSLT in XQuery looks like:

======== declare function local:w2u($w as element()?) as element()* { let $xslt := <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:wu="java:org.tbrc.saxon.Convert" xmlns:w="http://www.tbrc.org/models/work#" version="1.0"> <xsl:template match="w:title[@encoding='extendedWylie' or not(@encoding)]"> xsl:copy <xsl:apply-templates select="@[not(encoding)]"/> <xsl:attribute name="encoding">native</xsl:attribute> <xsl:value-of select="wu:toUnicode()"/> </xsl:copy> </xsl:template> <xsl:template match="w:creator|w:subject"> xsl:copy <xsl:apply-templates select="@"/> <xsl:value-of select="wu:toUnicode()"/> </xsl:copy> </xsl:template> <xsl:template match="@|node()"> xsl:copy <xsl:apply-templates select="@|node()"/> </xsl:copy> </xsl:template> </xsl:stylesheet> return transform:transform($w, $xslt, ()) };

The java extension itself is:

======== package org.tbrc.saxon;

import net.sf.saxon.expr.XPathContext; import net.sf.saxon.om.Item; import org.tbrc.common.shared.Converter;

public class Convert {

private static Converter converter = new Converter(true, true, true, false);

public static String toUnicode(XPathContext c) {
    
    Item item = c.getContextItem();
    if (item == null) {
    	return "";
    }
    // convert to Extended Wylie to Unicode
    String val = converter.toUnicode(item.getStringValue());

    if (val == null) {
        return "";
    }
    
    return val;
}

public static String toWylie(XPathContext c) {
    
    Item item = c.getContextItem();
    if (item == null) {
    	return "";
    }
    // convert to Extended Wylie to Unicode
    String val = converter.toWylie(item.getStringValue());

    if (val == null) {
        return "";
    }
    
    return val;
}

}

Thank you, Chris


Replies (2)

RE: Used to work but now "Cannot find a matching 0-argument function" - Added by O'Neil Delpratt about 9 years ago

Hi,

You have created the forum post in the Saxon/C project, which is incorrect. This is a Saxon core issues which should submitted on the Saxon project. See: https://saxonica.plan.io/projects/saxon/boards

From your description I suspect the problem to be related to a classpath. Have you changed the eXist-DB version?

RE: Used to work but now "Cannot find a matching 0-argument function" - Added by Michael Kay about 9 years ago

First, let's try and explain the circumstances in which you get this message.

First Saxon tries to bind the function call, using all available function libraries, including user-declared XQuery functions, built-in functions, constructor functions, Saxon extension functions, Java classpath, etc.

If this finds nothing that matches, then it tries to work out some possible explanations to include in the error message. The error message you report is produce after Saxon checks that:

  • It can load a Java class corresponding to the namespace

  • That class contains a method corresponding to the local name

  • Use of extension functions is not disabled

So Saxon has eliminated some of the possible causes of failing to find a matching function, and then it guesses, that the only other possible cause is that the number of arguments is wrong. I'm afraid this guess is not always right.

One other important cause that it hasn't eliminated (on the 9.4 path - fixed in later releases) is that there is no valid license file. In your case, looking at the evidence supplied, including the fact that it once worked, this seems the most likely explanation.

So I would suggest two courses of action:

(a) investigate possible license file problems

(b) get better diagnostics, by using the -TJ option or its API equivalent (FeatureKeys.TRACE_EXTERNAL_FUNCTIONS)

    (1-2/2)

    Please register to reply