use of net.sf.saxon.expr.XPathContextMajor in project ph-schematron by phax.
the class XPathFunctionFromUserFunction method evaluate.
@Nullable
public Object evaluate(final List aArgs) throws XPathFunctionException {
try {
// Convert the parameters
final Sequence[] aSequences = new Sequence[aArgs.size()];
if (aArgs.size() > 0) {
// Create a new context per evaluation
final XPathContextMajor aXPathContext = m_aXQController.newXPathContext();
int nIndex = 0;
for (final Object aArg : aArgs) {
// Ripped from Saxon itself; genericType is not needed
final JPConverter aConverter = JPConverter.allocate(aArg.getClass(), null, m_aConfiguration);
// Convert to Sequence
aSequences[nIndex] = aConverter.convert(aArg, aXPathContext);
++nIndex;
}
}
// Finally invoke user function
return m_aUserFunc.call(aSequences, m_aXQController);
} catch (final Exception ex) {
// Wrap all exceptions
throw new XPathFunctionException(ex);
}
}
Aggregations