final RequestModule myModule =
(RequestModule) context.getModule(RequestModule.NAMESPACE_URI);
// request object is read from global variable $request
final Variable var = myModule.resolveVariable(RequestModule.REQUEST_VAR);
if(var == null || var.getValue() == null)
{throw new XPathException(this, "No request object found in the current XQuery context.");}
if (var.getValue().getItemType() != Type.JAVA_OBJECT)
{throw new XPathException(this, "Variable $request is not bound to an Java object.");}
// get parameters
final String uploadParamName = args[0].getStringValue();
final JavaObjectValue value = (JavaObjectValue) var.getValue().itemAt(0);
if (value.getObject() instanceof RequestWrapper) {
final RequestWrapper request = (RequestWrapper)value.getObject();
final List<String> fnames = request.getUploadedFileName(uploadParamName);
if(fnames == null) {
return Sequence.EMPTY_SEQUENCE;