1 16 19 package org.apache.xalan.transformer; 20 21 import java.util.Enumeration ; 22 import java.util.Stack ; 23 24 import org.apache.xml.dtm.DTMIterator; 25 import org.apache.xml.utils.BoolStack; 26 import org.apache.xml.utils.IntStack; 27 import org.apache.xml.utils.NamespaceSupport2; 28 import org.apache.xml.utils.NodeVector; 29 import org.apache.xml.utils.ObjectStack; 30 import org.apache.xpath.VariableStack; 31 import org.apache.xpath.XPathContext; 32 33 import org.xml.sax.helpers.NamespaceSupport ; 34 35 import org.apache.xml.serializer.NamespaceMappings; 36 import org.apache.xml.serializer.SerializationHandler; 37 47 class TransformSnapshotImpl implements TransformSnapshot 48 { 49 50 53 private VariableStack m_variableStacks; 54 55 59 private IntStack m_currentNodes; 60 61 62 private IntStack m_currentExpressionNodes; 63 64 67 private Stack m_contextNodeLists; 68 69 72 private DTMIterator m_contextNodeList; 73 74 77 private Stack m_axesIteratorStack; 78 79 82 private BoolStack m_currentTemplateRuleIsNull; 83 84 90 private ObjectStack m_currentTemplateElements; 91 92 100 private Stack m_currentMatchTemplates; 101 102 110 private NodeVector m_currentMatchNodes; 111 112 116 private CountersTable m_countersTable; 117 118 122 private Stack m_attrSetStack; 123 124 125 boolean m_nsContextPushed; 126 127 130 private NamespaceMappings m_nsSupport; 131 132 133 135 143 TransformSnapshotImpl(TransformerImpl transformer) 144 { 145 146 try 147 { 148 149 SerializationHandler rtf = transformer.getResultTreeHandler(); 151 152 { 153 m_nsSupport = (NamespaceMappings)rtf.getNamespaceMappings().clone(); 155 156 } 158 159 XPathContext xpc = transformer.getXPathContext(); 160 161 m_variableStacks = (VariableStack) xpc.getVarStack().clone(); 162 m_currentNodes = (IntStack) xpc.getCurrentNodeStack().clone(); 163 m_currentExpressionNodes = 164 (IntStack) xpc.getCurrentExpressionNodeStack().clone(); 165 m_contextNodeLists = (Stack ) xpc.getContextNodeListsStack().clone(); 166 167 if (!m_contextNodeLists.empty()) 168 m_contextNodeList = 169 (DTMIterator) xpc.getContextNodeList().clone(); 170 171 m_axesIteratorStack = (Stack ) xpc.getAxesIteratorStackStacks().clone(); 172 m_currentTemplateRuleIsNull = 173 (BoolStack) transformer.m_currentTemplateRuleIsNull.clone(); 174 m_currentTemplateElements = 175 (ObjectStack) transformer.m_currentTemplateElements.clone(); 176 m_currentMatchTemplates = 177 (Stack ) transformer.m_currentMatchTemplates.clone(); 178 m_currentMatchNodes = 179 (NodeVector) transformer.m_currentMatchedNodes.clone(); 180 m_countersTable = 181 (CountersTable) transformer.getCountersTable().clone(); 182 183 if (transformer.m_attrSetStack != null) 184 m_attrSetStack = (Stack ) transformer.m_attrSetStack.clone(); 185 } 186 catch (CloneNotSupportedException cnse) 187 { 188 throw new org.apache.xml.utils.WrappedRuntimeException(cnse); 189 } 190 } 191 192 201 void apply(TransformerImpl transformer) 202 { 203 204 try 205 { 206 207 SerializationHandler rtf = transformer.getResultTreeHandler(); 209 210 if (rtf != null) 211 { 212 rtf.setNamespaceMappings((NamespaceMappings)m_nsSupport.clone()); 214 } 215 216 XPathContext xpc = transformer.getXPathContext(); 217 218 xpc.setVarStack((VariableStack) m_variableStacks.clone()); 219 xpc.setCurrentNodeStack((IntStack) m_currentNodes.clone()); 220 xpc.setCurrentExpressionNodeStack( 221 (IntStack) m_currentExpressionNodes.clone()); 222 xpc.setContextNodeListsStack((Stack ) m_contextNodeLists.clone()); 223 224 if (m_contextNodeList != null) 225 xpc.pushContextNodeList((DTMIterator) m_contextNodeList.clone()); 226 227 xpc.setAxesIteratorStackStacks((Stack ) m_axesIteratorStack.clone()); 228 229 transformer.m_currentTemplateRuleIsNull = 230 (BoolStack) m_currentTemplateRuleIsNull.clone(); 231 transformer.m_currentTemplateElements = 232 (ObjectStack) m_currentTemplateElements.clone(); 233 transformer.m_currentMatchTemplates = 234 (Stack ) m_currentMatchTemplates.clone(); 235 transformer.m_currentMatchedNodes = 236 (NodeVector) m_currentMatchNodes.clone(); 237 transformer.m_countersTable = (CountersTable) m_countersTable.clone(); 238 239 if (m_attrSetStack != null) 240 transformer.m_attrSetStack = (Stack ) m_attrSetStack.clone(); 241 } 242 catch (CloneNotSupportedException cnse) 243 { 244 throw new org.apache.xml.utils.WrappedRuntimeException(cnse); 245 } 246 } 247 } 248 | Popular Tags |