if (p1.getLength() == 0) {
throw new XPathException(ast.getLine(), ast.getColumn(),
"Second argument of near() is empty");
}
final Expression e1 = p1.getExpression(0);
final ExtNear near = new ExtNear(context);
near.setLocation(ast.getLine(), ast.getColumn());
near.addTerm(e1);
near.setPath((PathExpr) params.get(0));
if (params.size() > 2) {
p1 = (PathExpr) params.get(2);
if (p1.getLength() == 0) {
throw new XPathException(ast.getLine(), ast.getColumn(),
"Max distance argument of near() is empty");
}
near.setMaxDistance(p1);
if (params.size() == 4) {
p1 = (PathExpr) params.get(3);
if(p1.getLength() == 0) {
throw new XPathException(ast.getLine(), ast.getColumn(),
"Min distance argument of near() is empty");
}
near.setMinDistance(p1);
}
}
return near;
}