public Sequence eval(Sequence[] args, Sequence contextSequence)
throws XPathException {
try {
if(isCalledAs("encode")) {
return new StringValue(URIUtils.urlEncodePartsUtf8(args[0].getStringValue()));
} else if(isCalledAs("encode-uri")) {
return new AnyURIValue(URIUtils.encodeXmldbUriFor(args[0].getStringValue()));
} else {
return new StringValue(URIUtils.urlDecodeUtf8(args[0].getStringValue()));
}
} catch(final URISyntaxException e) {
logger.error(e.getMessage(), e);
throw new XPathException(this, "URI Syntax Exception: " + e.getMessage(), e);
} finally {