public void setFallbackFunction(Map<String, Sequence<?>> options, XPathContext context) throws XPathException { Sequence<?> val = options.get("fallback"); if (val != null) { Item fn = val.head(); if (fn instanceof Function) { fallbackFunction = (Function) fn; if (fallbackFunction.getArity() != 1) { throw new XPathException("Fallback function must have arity=1", "FOJS0005"); } SpecificFunctionType required = new SpecificFunctionType( new SequenceType[]{SequenceType.SINGLE_STRING}, SequenceType.ANY_SEQUENCE); if (!required.matches(fallbackFunction, context.getConfiguration().getTypeHierarchy())) { throw new XPathException("Fallback function does not match the required type", "FOJS0005"); } } else { throw new XPathException("Value of option 'fallback' is not a function", "FOJS0005"); } } } }
public void setFallbackFunction(Map<String, Sequence<?>> options, XPathContext context) throws XPathException { Sequence<?> val = options.get("fallback"); if (val != null) { Item fn = val.head(); if (fn instanceof Function) { fallbackFunction = (Function) fn; if (fallbackFunction.getArity() != 1) { throw new XPathException("Fallback function must have arity=1", "FOJS0005"); } SpecificFunctionType required = new SpecificFunctionType( new SequenceType[]{SequenceType.SINGLE_STRING}, SequenceType.ANY_SEQUENCE); if (!required.matches(fallbackFunction, context.getConfiguration().getTypeHierarchy())) { throw new XPathException("Fallback function does not match the required type", "FOJS0005"); } } else { throw new XPathException("Value of option 'fallback' is not a function", "FOJS0005"); } } } }