Я зарегистрировал ExtensionFunctionDefinition без параметров, но не могу его вызвать.
Что не так и как это можно исправить?
Похоже, что функция не зарегистрирована.
Вот код:
саксонский
...<saxon.he.version>9.7.0-3</saxon.he.version>...
<groupId>net.sf.saxon</groupId>
<artifactId>Saxon-HE</artifactId>...
Исключение
Error at char 29 in xsl:value-of/@select on line 23 column 71
XTDE1425: Cannot find a matching 0-argument function named {http://date.com}getFormattedNow()
in built-in template rule
XSLT
<xsl:stylesheet ...
xmlns:dateService="http://date.com"
exclude-result-prefixes="dateService" version="1.0">
...
<xsl:value-of select="dateService:getFormattedNow()"/>
ExtensionFunctionDefinition
public class DateExtensionFunction extends ExtensionFunctionDefinition {
public StructuredQName getFunctionQName() {
return new StructuredQName("", "http://date.com", "getFormattedNow");
}
public SequenceType[] getArgumentTypes() {
return new SequenceType[]{SequenceType.OPTIONAL_STRING};
}
public SequenceType getResultType(SequenceType[] sequenceTypes) {
return SequenceType.SINGLE_STRING;
}
public boolean trustResultType() {
return true;
}
public int getMinimumNumberOfArguments() {
return 0;
}
public int getMaximumNumberOfArguments() {
return 1;
}
public ExtensionFunctionCall makeCallExpression() {
return new ExtensionFunctionCall() {
public Sequence call(XPathContext context, Sequence[] arguments) throws XPathException {
return new StringValue("TEST");
}
};
}
}
Трансформер
Processor processor = new Processor(false);
Configuration configuration = new Configuration();
TransformerFactoryImpl transformerFactory = new TransformerFactoryImpl();
processor.registerExtensionFunction(new DateExtensionFunction());
configuration.setProcessor(processor);
transformerFactory.setConfiguration(configuration);
//...newTransformer