1 package net.sf.saxon.style; 2 import net.sf.saxon.expr.Expression; 3 import net.sf.saxon.expr.ExpressionTool; 4 import net.sf.saxon.instruct.Assign; 5 import net.sf.saxon.instruct.Executable; 6 import net.sf.saxon.trans.XPathException; 7 8 13 14 public class SaxonAssign extends XSLGeneralVariable { 15 16 private XSLVariableDeclaration declaration; private Assign instruction = new Assign(); 18 19 23 24 public boolean isInstruction() { 25 return true; 26 } 27 28 public boolean isAssignable() { return true; 30 } 31 32 protected boolean allowsAsAttribute() { 33 return false; 34 } 35 36 public void validate() throws XPathException { 37 checkWithinTemplate(); 38 super.validate(); 39 try { 40 declaration = bindVariable(getVariableFingerprint()); 41 declaration.registerReference(instruction); 42 requiredType = declaration.getRequiredType(); 43 } catch (XPathException err) { 44 compileError(err.getMessage()); 46 return; 47 } 48 if (!declaration.isAssignable()) { 49 compileError("Variable " + getVariableName() + " is not marked as assignable"); 50 } 51 if (!declaration.isGlobal()) { 52 compileError("saxon:assign now works only with global variables"); 53 } 54 } 55 56 public Expression compile(Executable exec) throws XPathException { 57 initializeInstruction(exec, instruction); 58 ExpressionTool.makeParentReferences(instruction); 59 return instruction; 60 } 61 62 } 63 64 | Popular Tags |