@Override public void endUnionExpr(boolean create) { ArrayDeque stack = popFrame(); if (create) { LocationPath result = new LocationPath(Scope.LOCAL, 0); result.addToContext((LocationPath) stack.pollFirst()); result.addToContext((LocationPath) stack.pollFirst()); push(result); } else push(stack.peek()); }
@Override public void endPathExpr() { Object relative = pop(); Object context = pop(); if (relative instanceof LocationPath && context instanceof LocationPath) { ((LocationPath) relative).pathExpression = true; ((LocationPath) relative).addToContext((LocationPath) context); context = pop(); } if (context != PATH_FLAG) throw new NotImplementedException("Path"); push(relative); }
private Expression createFunction(String name, ArrayDeque params) throws SAXPathException { int noOfParams = params.size(); switch (noOfParams) { case 0: { LocationPath locationPath = predicateDepth == 0 ? LocationPath.DOCUMENT_CONTEXT : LocationPath.LOCAL_CONTEXT; Expression expr = locationPath.apply(name); if (expr != null) return expr; return createFunction(name, 0); } case 1: { if (name.equals("lang")) { langInterested = true; FunctionCall functionCall = new FunctionCall(Functions.LANGUAGE_MATCH); functionCall.addValidMember(new Language(), 0); functionCall.addMember(params.pollFirst(), 1); return functionCall; } else { Object current = params.pollFirst(); if (current instanceof LocationPath) { Expression expr = ((LocationPath) current).apply(name); if (expr != null) return expr; } FunctionCall functionCall = (FunctionCall) createFunction(name, 1); functionCall.addMember(current, 0); return functionCall; } } default: FunctionCall functionCall = (FunctionCall) createFunction(name, noOfParams); for (int i = 0; i < noOfParams; i++) functionCall.addMember(params.pollFirst(), i); return functionCall; } }