Saxon, the transformation and validation engine used by Oxygen XML Author Eclipse plugin, can be customized by adding custom functions (called Integrated Extension Functions) that can be called from XPath.
net.sf.saxon.lib.ExtensionFunctionDefinition. Here is an
example:private static 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() {
public SequenceIterator call(SequenceIterator[] arguments, XPathContext context)
throws XPathException {
long v0 = ((IntegerValue)arguments[0].next()).longValue();
long v1 = ((IntegerValue)arguments[1].next()).longValue();
long result = v0<<v1;
return Value.asIterator(Int64Value.makeIntegerValue(result));
}
};
}
}