1 22 23 package org.xquark.xquery.normalize; 24 25 import java.util.ArrayList ; 26 27 import org.xquark.xquery.parser.*; 28 29 30 31 public class SetVariablePathsVisitor extends DefaultParserVisitor { 32 33 private static final String RCSRevision = "$Revision: 1.1 $"; 34 private static final String RCSName = "$Name: $"; 35 36 37 public SetVariablePathsVisitor() {} 38 39 public void visit(Element arg) throws XQueryException { 40 if (arg.getStartTag() != null) { 41 arg.getStartTag().accept(this); 42 } 43 if (arg.getAttributes() != null) { 44 for (int i = 0; i < arg.getAttributes().size(); i++) { 45 ((AttributeValuePair)arg.getAttributes().get(i)).accept(this); 46 } 47 } 48 if (arg.getSubExpressions() != null) { 49 for (int j = 0; j < arg.getSubExpressions().size(); j++) { 50 ((XQueryExpression)arg.getSubExpressions().get(j)).accept(this); 51 } 52 } 53 } 54 55 public void visit(FunctionCall arg) throws XQueryException { 56 if (arg.getArguments() != null) { 57 for (int i = 0; i < arg.getArguments().size(); i++) { 58 ((XQueryExpression)arg.getArguments().get(i)).accept(this); 59 } 60 } 61 } 62 63 public void visit(FLWRExpression arg) throws XQueryException { 64 ArrayList list = arg.getVariables(); 65 for (int i=0;i<list.size();i++) { 66 XQueryExpression expri = ((Variable)list.get(i)).getExpression(); 67 if (expri instanceof FLWRExpression) 68 expri.accept(this); 69 } 70 list = arg.getOrderBy(); 71 if (list != null) 72 for (int i=0;i<list.size();i++) 73 ((XQueryExpression)list.get(i)).accept(this); 74 if (arg.getReturnClause() instanceof FLWRExpression) 75 arg.getReturnClause().accept(this); 76 } 77 78 public void visit(LocatedExpression arg) throws XQueryException { 79 if (arg.getExpression() instanceof Variable) { 80 ((Variable)arg.getExpression()).addSubPath(arg); 81 } 82 } 83 84 public void visit(Variable arg) throws XQueryException { 85 arg.addSubPath(arg); 86 } 87 88 public void visit(ITEExpression arg) throws XQueryException { 89 arg.getIfExpression().accept(this); 90 arg.getThenExpression().accept(this); 91 arg.getElseExpression().accept(this); 92 } 93 94 public void visit(XQueryBinaryOperatorExpression arg) throws XQueryException { 95 if (arg.getExpression1() != null) { 96 arg.getExpression1().accept(this); 97 } 98 if (arg.getExpression2() != null) { 99 arg.getExpression2().accept(this); 100 } 101 } 102 103 104 106 107 public void visit(XQueryExpressionSequence arg) throws XQueryException { 108 for (int i = 0; i < arg.getSubExpressions().size(); i++) { 109 ((XQueryExpression)arg.getSubExpressions().get(i)).accept(this); 110 } 111 } 112 113 public void visit(XQueryUnaryOperatorExpression arg) throws XQueryException { 114 if (arg.getExpression() != null) { 115 arg.getExpression().accept(this); 116 } 117 } 118 119 120 } 121 | Popular Tags |