1 package net.sf.saxon.instruct; 2 3 import net.sf.saxon.expr.*; 4 import net.sf.saxon.om.ValueRepresentation; 5 import net.sf.saxon.style.StandardNames; 6 import net.sf.saxon.trans.DynamicError; 7 import net.sf.saxon.trans.XPathException; 8 9 import java.util.Collections ; 10 import java.util.Iterator ; 11 12 20 21 public final class LocalParam extends GeneralVariable { 22 23 private Expression conversion = null; 24 25 29 public void setConversion(Expression convertor) { 30 conversion = convertor; 31 } 32 33 36 37 public int getInstructionNameCode() { 38 return StandardNames.XSL_PARAM; 39 } 40 41 46 47 public Iterator iterateSubExpressions() { 48 if (select != null && conversion != null) { 49 return new PairIterator(select, conversion); 50 } else if (select != null) { 51 return new MonoIterator(select); 52 } else if (conversion != null) { 53 return new MonoIterator(conversion); 54 } else { 55 return Collections.EMPTY_LIST.iterator(); 56 } 57 } 58 59 62 63 public TailCall processLeavingTail(XPathContext context) throws XPathException { 64 boolean wasSupplied = context.useLocalParameter(getVariableFingerprint(), this, isTunnelParam()); 65 if (wasSupplied) { 66 if (conversion != null) { 68 context.setLocalVariable(getSlotNumber(), 69 ExpressionTool.eagerEvaluate(conversion, context)); 70 } 74 75 78 } else { 79 if (isRequiredParam()) { 80 DynamicError e = new DynamicError("No value supplied for required parameter"); 81 e.setXPathContext(context); 82 e.setErrorCode("XTDE0700"); 83 throw e; 84 } 85 context.setLocalVariable(getSlotNumber(), getSelectValue(context)); 86 } 87 return null; 88 } 89 90 93 94 public ValueRepresentation evaluateVariable(XPathContext c) { 95 return c.evaluateLocalVariable(getSlotNumber()); 96 } 97 } 98 99 | Popular Tags |