1 package com.icl.saxon.style; 2 import com.icl.saxon.tree.AttributeCollection; 3 import com.icl.saxon.*; 4 import com.icl.saxon.om.NodeInfo; 5 import com.icl.saxon.handlers.*; 6 import com.icl.saxon.expr.*; 7 8 import javax.xml.transform.*; 9 import java.io.*; 10 11 15 16 public class XSLParam extends XSLGeneralVariable implements Binding { 17 18 private int slotNumber; 19 20 public int getSlotNumber() { 21 return slotNumber; 22 } 23 24 public void validate() throws TransformerConfigurationException { 25 26 super.validate(); 27 28 NodeInfo parent = (NodeInfo)getParentNode(); 29 boolean local = (parent instanceof XSLTemplate || parent instanceof SAXONFunction); 30 31 if (!local && !global) { 32 compileError("xsl:param must be immediately within a template, function or stylesheet"); 33 } 34 35 checkDuplicateDeclaration(); 36 37 if (global && !redundant) { 38 slotNumber = getPrincipalStyleSheet().allocateSlotNumber(); 39 } else { 40 Procedure p = getOwningProcedure(); 41 slotNumber = p.allocateSlotNumber(); 42 } 43 44 if (!global) { 45 NodeInfo preceding = (NodeInfo)getPreviousSibling(); 46 if (preceding!=null && !(preceding instanceof XSLParam)) { 47 compileError("xsl:param must be the first element within a template"); 48 } 49 } 50 51 } 52 53 public void process(Context context) throws TransformerException 54 { 55 if (redundant) return; 56 57 Bindery bindery = context.getBindery(); 58 boolean wasSupplied; 59 60 if (global) { 61 wasSupplied = bindery.useGlobalParameter(variableFingerprint, this); 62 } else { 63 wasSupplied = bindery.useLocalParameter(variableFingerprint, this); 64 } 65 66 69 if (!wasSupplied) { 70 if (global) { 71 if (!redundant) { 72 Value value = getSelectValue(context); 73 bindery.defineGlobalVariable(this, value); 74 } 75 } else { 76 Value value = getSelectValue(context); 77 bindery.defineLocalVariable(this, value); 78 } 79 } 80 } 81 82 86 87 public int getDataType() { 88 return Value.ANY; 89 } 90 91 95 96 public Value constantValue() { 97 return null; 98 } 99 } 100 101 | Popular Tags |