List of usage examples for org.apache.commons.jxpath.ri.compiler Operation getArguments
public Expression[] getArguments()
From source file:org.chiba.xml.xpath.impl.JXPathReferenceFinderImpl.java
private void addExpressionReferences(Map references, Expression context, Expression expression) { // handle location pathes like "../relative/path" or "//absolute/path" if (expression instanceof LocationPath) { // put location path in context and add as reference LocationPath locationPath = (LocationPath) expression; Path path = addLocationPath(context, (LocationPath) expression); references.put(path.toString(), path); // pass empty location path when there is no context Expression contextExpression = (Expression) (context == null ? this.compiler.locationPath(locationPath.isAbsolute(), null) : context);//w w w . java2s . co m // add references of step predicates addStepReferences(references, contextExpression, locationPath.getSteps()); return; } // handle expression pathes like "instance('id')/path" or "ext:function()[predicate]/path" if (expression instanceof ExpressionPath) { // add expression path as reference ExpressionPath expressionPath = (ExpressionPath) expression; references.put(expressionPath.toString(), expressionPath); // add references in expression predicates Expression[] predicates = expressionPath.getPredicates(); for (int i = 0; predicates != null && i < predicates.length; i++) { addExpressionReferences(references, expressionPath.getExpression(), predicates[i]); } // add references in step predicates addStepReferences(references, expressionPath.getExpression(), expressionPath.getSteps()); return; } // handle standalone instance() function if (expression instanceof ExtensionFunction) { ExtensionFunction function = (ExtensionFunction) expression; // todo: how to handle all functions returning a nodeset ? if (function.getFunctionName().getName().equals("instance")) { references.put(expression.toString(), expression); return; } } // handle all other operations like "black + white" or "count(../apples and /oranges)" if (expression instanceof Operation) { Operation operation = (Operation) expression; Expression[] arguments = operation.getArguments(); // add references in function arguments for (int i = 0; arguments != null && i < arguments.length; i++) { addExpressionReferences(references, context, arguments[i]); } } // don't handle constants // if (expression instanceof Constant) { // } // don't handle variable references (maybe needed someday) // if (expression instanceof VariableReference) { // } }
From source file:org.xchain.framework.jxpath.JXPathValidator.java
static void validateOperation(Operation operation, NamespaceContext xmlns) { if (operation.getArguments() != null) for (Expression argument : operation.getArguments()) { validateExpression(argument, xmlns); }//from w w w .ja v a 2s .co m if (operation instanceof ExtensionFunction) { validateExtensionFunction((ExtensionFunction) operation, xmlns); } // ASSERT: all other types of operations do not need validation. }