colpath = "/";
} else {
XQExpression argExpr = params.get(0);
colpath = argExpr.eval(null, DynamicContext.DUMMY).toString();
}
MapExpr mapExpr = new MapExpr(colpath, bindingVar, flwrExpr);
return mapExpr.staticAnalysis(statEnv);
}
}
}
} else if(expr instanceof PathExpr) {
PathExpr pathExpr = (PathExpr) expr;
List<XQExpression> steps = pathExpr.getSteps();
if(steps.size() > 1) {
XQExpression firstStep = steps.get(0);
if(firstStep instanceof DirectFunctionCall) {
DirectFunctionCall funcall = (DirectFunctionCall) firstStep;
if(FnCollection.FUNC_NAME.equals(funcall.getFuncName())) {
List<XQExpression> params = funcall.getParams();
final String colpath;
if(params.isEmpty()) {
colpath = "/";
} else {
XQExpression argExpr = params.get(0);
colpath = argExpr.eval(null, DynamicContext.DUMMY).toString();
}
FLWRExpr newFlwr = new FLWRExpr();
ForVariable forVar = new ForVariable();
forVar.setValue(funcall);
newFlwr.addClause(new ForClause(forVar));
VarRef varref = new VarRef(forVar);
steps.set(0, varref);
newFlwr.setFilteredReturnExpr(pathExpr);
MapExpr mapExpr = new MapExpr(colpath, forVar, newFlwr);
return mapExpr.staticAnalysis(statEnv);
}
}
}
}
}