Actions
Support #4184
closedError: Invalid configuration property extensionFunction
Status:
Closed
Priority:
Low
Assignee:
-
Category:
-
Sprint/Milestone:
-
Start date:
2019-03-28
Due date:
% Done:
0%
Estimated time:
Legacy ID:
Applies to branch:
9.9
Fix Committed on Branch:
Fixed in Maintenance Release:
Platforms:
Description
While trying to create a Java extension function (full interface) and use it via the command line, I've been unable to successfully register the extension when declaring it in a configuration file.
Configuration File¶
<configuration xmlns="http://saxon.sf.net/ns/configuration"
edition="EE">
<resources>
<extensionFunction>com.example.ShiftLeft</extensionFunction>
</resources>
</configuration>
Extension Function Definition¶
package com.example;
import net.sf.saxon.lib.ExtensionFunctionCall;
import net.sf.saxon.lib.ExtensionFunctionDefinition;
import net.sf.saxon.om.Sequence;
import net.sf.saxon.om.StructuredQName;
import net.sf.saxon.trans.XPathException;
import net.sf.saxon.expr.XPathContext;
import net.sf.saxon.value.SequenceType;
import net.sf.saxon.value.IntegerValue;
import net.sf.saxon.value.Int64Value;
// Based upon:
// http://www.saxonica.com/html/documentation/extensibility/integratedfunctions/ext-full-J.html
class ShiftLeft extends ExtensionFunctionDefinition {
@Override
public StructuredQName getFunctionQName() {
return new StructuredQName("eg", "http://example.com/saxon-extension", "shift-left");
}
@Override
public SequenceType[] getArgumentTypes() {
return new SequenceType[]{SequenceType.SINGLE_INTEGER, SequenceType.SINGLE_INTEGER};
}
@Override
public SequenceType getResultType(SequenceType[] suppliedArgumentTypes) {
return SequenceType.SINGLE_INTEGER;
}
@Override
public ExtensionFunctionCall makeCallExpression() {
return new ExtensionFunctionCall() {
@Override
public Sequence call(XPathContext context, Sequence[] arguments) throws XPathException {
long v0 = ((IntegerValue)arguments[0]).longValue();
long v1 = ((IntegerValue)arguments[1]).longValue();
long result = v0<<v1;
return Int64Value.makeIntegerValue(result);
}
};
}
}
Error¶
[xslt] Warning on line 4 column 65 of saxon_config.xml:
[xslt] Invalid configuration property extensionFunction. Supplied value 'com.example.ShiftLeft',
[xslt] required value is the name of a class that implements
[xslt] 'net.sf.saxon.lib.ExtensionFunctionDefinition': Failed to instantiate class
[xslt] com.example.ShiftLeft: class net.sf.saxon.trans.DynamicLoader cannot access a member of
[xslt] class com.example.ShiftLeft with modifiers ""
I've attached a complete, ant-driven example that exhibits the problem I'm having. Hope this helps in reproducing it, or (more likely) spotting the error in my ways.
Thank you,
Kenneth J Hughes
Files
Please register to edit this issue
Actions