00001 /* 00002 * The Apache Software License, Version 1.1 00003 * 00004 * 00005 * Copyright (c) 2000-2002 The Apache Software Foundation. All rights 00006 * reserved. 00007 * 00008 * Redistribution and use in source and binary forms, with or without 00009 * modification, are permitted provided that the following conditions 00010 * are met: 00011 * 00012 * 1. Redistributions of source code must retain the above copyright 00013 * notice, this list of conditions and the following disclaimer. 00014 * 00015 * 2. Redistributions in binary form must reproduce the above copyright 00016 * notice, this list of conditions and the following disclaimer in 00017 * the documentation and/or other materials provided with the 00018 * distribution. 00019 * 00020 * 3. The end-user documentation included with the redistribution, 00021 * if any, must include the following acknowledgment: 00022 * "This product includes software developed by the 00023 * Apache Software Foundation (http://www.apache.org/)." 00024 * Alternately, this acknowledgment may appear in the software itself, 00025 * if and wherever such third-party acknowledgments normally appear. 00026 * 00027 * 4. The names "Xalan" and "Apache Software Foundation" must 00028 * not be used to endorse or promote products derived from this 00029 * software without prior written permission. For written 00030 * permission, please contact apache@apache.org. 00031 * 00032 * 5. Products derived from this software may not be called "Apache", 00033 * nor may "Apache" appear in their name, without prior written 00034 * permission of the Apache Software Foundation. 00035 * 00036 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 00037 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00038 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00039 * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR 00040 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00041 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00042 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 00043 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 00044 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00045 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 00046 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 00047 * SUCH DAMAGE. 00048 * ==================================================================== 00049 * 00050 * This software consists of voluntary contributions made by many 00051 * individuals on behalf of the Apache Software Foundation and was 00052 * originally based on software copyright (c) 1999, International 00053 * Business Machines, Inc., http://www.ibm.com. For more 00054 * information on the Apache Software Foundation, please see 00055 * <http://www.apache.org/>. 00056 */ 00057 #if !defined(XALAN_VARIABLESSTACK_HEADER_GUARD) 00058 #define XALAN_VARIABLESSTACK_HEADER_GUARD 00059 00060 00061 00062 // Base include file. Must be first. 00063 #include <xalanc/XSLT/XSLTDefinitions.hpp> 00064 00065 00066 00067 #include <cassert> 00068 #include <vector> 00069 00070 00071 00072 #include <xalanc/XPath/XalanQName.hpp> 00073 #include <xalanc/XPath/XObject.hpp> 00074 00075 00076 00077 #include <xalanc/XSLT/XSLTProcessorException.hpp> 00078 00079 00080 00081 XALAN_CPP_NAMESPACE_BEGIN 00082 00083 00084 00085 class Arg; 00086 class ElemTemplateElement; 00087 class ElemVariable; 00088 class StylesheetExecutionContext; 00089 class XalanNode; 00090 00091 00092 00096 class XALAN_XSLT_EXPORT VariablesStack 00097 { 00098 public: 00099 00103 explicit 00104 VariablesStack(); 00105 00106 ~VariablesStack(); 00107 00108 00112 void 00113 reset(); 00114 00120 void 00121 pushElementFrame(const ElemTemplateElement* elem); 00122 00128 void 00129 popElementFrame(const ElemTemplateElement* elem); 00130 00138 void 00139 pushContextMarker(); 00140 00144 void 00145 popContextMarker(); 00146 00147 struct ParamsVectorEntry 00148 { 00149 ParamsVectorEntry() : 00150 m_qname(0), 00151 m_value(), 00152 m_variable(0) 00153 { 00154 } 00155 00156 ParamsVectorEntry( 00157 const XalanQName* qname, 00158 const XObjectPtr value) : 00159 m_qname(qname), 00160 m_value(value), 00161 m_variable(0) 00162 { 00163 } 00164 00165 ParamsVectorEntry( 00166 const XalanQName* qname, 00167 const ElemVariable* variable) : 00168 m_qname(qname), 00169 m_value(), 00170 m_variable(variable) 00171 { 00172 } 00173 00174 const XalanQName* m_qname; 00175 00176 XObjectPtr m_value; 00177 00178 const ElemVariable* m_variable; 00179 }; 00180 00181 #if defined(XALAN_NO_STD_NAMESPACE) 00182 typedef vector<ParamsVectorEntry> ParamsVectorType; 00183 typedef vector<const ElemVariable*> RecursionGuardStackType; 00184 #else 00185 typedef std::vector<ParamsVectorEntry> ParamsVectorType; 00186 typedef std::vector<const ElemVariable*> RecursionGuardStackType; 00187 #endif 00188 00196 void 00197 pushParams( 00198 const ParamsVectorType& theParams, 00199 const ElemTemplateElement* targetTemplate); 00200 00211 const XObjectPtr 00212 getParamVariable( 00213 const XalanQName& qname, 00214 StylesheetExecutionContext& executionContext, 00215 bool& fNameFound) 00216 { 00217 return findXObject(qname, executionContext, true, false, fNameFound); 00218 } 00219 00231 const XObjectPtr 00232 getVariable( 00233 const XalanQName& qname, 00234 StylesheetExecutionContext& executionContext, 00235 bool& fNameFound) 00236 { 00237 return findXObject(qname, executionContext, false, true, fNameFound); 00238 } 00239 00249 void 00250 pushVariable( 00251 const XalanQName& name, 00252 const ElemVariable* var, 00253 const ElemTemplateElement* e); 00254 00264 void 00265 pushVariable( 00266 const XalanQName& name, 00267 const XObjectPtr& val, 00268 const ElemTemplateElement* e); 00269 00273 void 00274 start(); 00275 00279 void 00280 resetParams(); 00281 00285 void 00286 markGlobalStackFrame(); 00287 00291 void 00292 unmarkGlobalStackFrame(); 00293 00301 void 00302 setCurrentStackFrameIndex(int currentStackFrameIndex = -1) 00303 { 00304 if (currentStackFrameIndex == -1) 00305 m_currentStackFrameIndex = m_stack.size(); 00306 else 00307 m_currentStackFrameIndex = currentStackFrameIndex; 00308 } 00309 00316 int 00317 getCurrentStackFrameIndex() const 00318 { 00319 return m_currentStackFrameIndex; 00320 } 00321 00327 int 00328 getGlobalStackFrameIndex() const 00329 { 00330 return m_globalStackFrameIndex; 00331 } 00332 00333 class InvalidStackContextException : public XSLTProcessorException 00334 { 00335 public: 00336 00337 InvalidStackContextException(); 00338 00339 virtual 00340 ~InvalidStackContextException(); 00341 00342 private: 00343 00344 }; 00345 00346 class PushParamFunctor 00347 { 00348 public: 00349 00350 PushParamFunctor(VariablesStack& theVariablesStack) : 00351 m_variablesStack(theVariablesStack) 00352 { 00353 } 00354 00355 void 00356 operator()(const ParamsVectorType::value_type& theEntry) const; 00357 00358 private: 00359 00360 VariablesStack& m_variablesStack; 00361 }; 00362 00363 class XALAN_XSLT_EXPORT StackEntry 00364 { 00365 public: 00366 00371 enum eType { eContextMarker, 00372 eVariable, 00373 eParam, 00374 eActiveParam, 00375 eElementFrameMarker, 00376 eNextValue }; 00377 00381 explicit 00382 StackEntry(); 00383 00387 StackEntry( 00388 const XalanQName* name, 00389 const XObjectPtr& val, 00390 bool isParam = false); 00391 00395 StackEntry( 00396 const XalanQName* name, 00397 const ElemVariable* var, 00398 bool isParam = false); 00399 00403 StackEntry(const ElemTemplateElement* elem); 00404 00405 00409 StackEntry(const StackEntry& theSource); 00410 00414 ~StackEntry(); 00415 00421 eType 00422 getType() const 00423 { 00424 return m_type; 00425 } 00426 00432 const XalanQName* 00433 getName() const 00434 { 00435 return m_qname; 00436 } 00437 00443 const XObjectPtr& 00444 getValue() const 00445 { 00446 return m_value; 00447 } 00448 00454 void 00455 setValue(const XObjectPtr& theValue) 00456 { 00457 m_value = theValue; 00458 } 00459 00465 const ElemVariable* 00466 getVariable() const 00467 { 00468 return m_variable; 00469 } 00470 00471 void 00472 activate(); 00473 00474 void 00475 deactivate(); 00476 00482 const ElemTemplateElement* 00483 getElement() const 00484 { 00485 return m_element; 00486 } 00487 00488 StackEntry& 00489 operator=(const StackEntry& theRHS); 00490 00491 bool 00492 operator==(const StackEntry& theRHS) const; 00493 00494 private: 00495 00496 // Data members... 00497 eType m_type; 00498 00499 const XalanQName* m_qname; 00500 00501 XObjectPtr m_value; 00502 00503 const ElemVariable* m_variable; 00504 00505 const ElemTemplateElement* m_element; 00506 }; 00507 00508 #if defined(XALAN_NO_STD_NAMESPACE) 00509 typedef vector<StackEntry> VariableStackStackType; 00510 #else 00511 typedef std::vector<StackEntry> VariableStackStackType; 00512 #endif 00513 00514 enum { eDefaultStackSize = 100 }; 00515 00516 private: 00517 00525 bool 00526 elementFrameAlreadyPushed(const ElemTemplateElement* elem) const; 00527 00533 void 00534 push(const StackEntry& theEntry); 00535 00539 void 00540 pop(); 00541 00547 const StackEntry& 00548 back() const 00549 { 00550 assert(m_stack.empty() == false); 00551 00552 return m_stack.back(); 00553 } 00554 00555 friend class CommitPushElementFrame; 00556 friend class EnsurePop; 00557 friend class PushParamFunctor; 00558 friend class SetAndRestoreForceGlobalSearch; 00559 00560 const XObjectPtr 00561 findXObject( 00562 const XalanQName& name, 00563 StylesheetExecutionContext& executionContext, 00564 bool fIsParam, 00565 bool fSearchGlobalSpace, 00566 bool& fNameFound); 00567 00568 VariableStackStackType::size_type 00569 findEntry( 00570 const XalanQName& name, 00571 bool fIsParam, 00572 bool fSearchGlobalSpace); 00573 00574 00575 VariableStackStackType m_stack; 00576 00577 int m_globalStackFrameIndex; 00578 00579 bool m_globalStackFrameMarked; 00580 00586 unsigned int m_currentStackFrameIndex; 00587 00593 RecursionGuardStackType m_guardStack; 00594 }; 00595 00596 00597 00598 XALAN_CPP_NAMESPACE_END 00599 00600 00601 00602 #endif // #if !defined(XALAN_VARIABLESSTACK_HEADER_GUARD)
Doxygen and GraphViz are used to generate this API documentation from the Xalan-C header files.
![]() |
Xalan-C++ XSLT Processor Version 1.6 |
|