1 16 19 package org.apache.xalan.templates; 20 21 import javax.xml.transform.TransformerException ; 22 23 import org.apache.xalan.transformer.TransformerImpl; 24 import org.apache.xpath.XPath; 25 import org.apache.xpath.XPathContext; 26 import org.apache.xpath.objects.XObject; 27 28 40 public class ElemIf extends ElemTemplateElement 41 { 42 43 47 private XPath m_test = null; 48 49 55 public void setTest(XPath v) 56 { 57 m_test = v; 58 } 59 60 66 public XPath getTest() 67 { 68 return m_test; 69 } 70 71 81 public void compose(StylesheetRoot sroot) throws TransformerException 82 { 83 84 super.compose(sroot); 85 86 java.util.Vector vnames = sroot.getComposeState().getVariableNames(); 87 88 if (null != m_test) 89 m_test.fixupVariables(vnames, sroot.getComposeState().getGlobalsSize()); 90 } 91 92 98 public int getXSLToken() 99 { 100 return Constants.ELEMNAME_IF; 101 } 102 103 108 public String getNodeName() 109 { 110 return Constants.ELEMNAME_IF_STRING; 111 } 112 113 126 public void execute(TransformerImpl transformer) throws TransformerException 127 { 128 129 XPathContext xctxt = transformer.getXPathContext(); 130 int sourceNode = xctxt.getCurrentNode(); 131 132 if (TransformerImpl.S_DEBUG) 133 { 134 XObject test = m_test.execute(xctxt, sourceNode, this); 135 136 if (TransformerImpl.S_DEBUG) 137 transformer.getTraceManager().fireSelectedEvent(sourceNode, this, 138 "test", m_test, test); 139 140 143 if (TransformerImpl.S_DEBUG) 144 transformer.getTraceManager().fireTraceEvent(this); 145 146 if (test.bool()) 147 { 148 transformer.executeChildTemplates(this, true); 149 } 150 151 if (TransformerImpl.S_DEBUG) 152 transformer.getTraceManager().fireTraceEndEvent(this); 153 154 } 159 else if (m_test.bool(xctxt, sourceNode, this)) 160 { 161 transformer.executeChildTemplates(this, true); 162 } 163 164 } 165 166 170 protected void callChildVisitors(XSLTVisitor visitor, boolean callAttrs) 171 { 172 if(callAttrs) 173 m_test.getExpression().callVisitors(m_test, visitor); 174 super.callChildVisitors(visitor, callAttrs); 175 } 176 177 } 178 | Popular Tags |