00001 /* 00002 * The Apache Software License, Version 1.1 00003 * 00004 * 00005 * Copyright (c) 2000 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 <XSLT/XSLTDefinitions.hpp> 00064 00065 00066 00067 #include <cassert> 00068 #include <vector> 00069 00070 00071 00072 #include <XPath/XalanQName.hpp> 00073 #include <XPath/XObject.hpp> 00074 00075 00076 00077 #include <XSLT/XSLTProcessorException.hpp> 00078 00079 00080 00081 class Arg; 00082 class ElemTemplateElement; 00083 class ElemVariable; 00084 class StylesheetExecutionContext; 00085 class XalanNode; 00086 00087 00088 00092 class XALAN_XSLT_EXPORT VariablesStack 00093 { 00094 public: 00095 00099 explicit 00100 VariablesStack(); 00101 00102 ~VariablesStack(); 00103 00104 00108 void 00109 reset(); 00110 00116 void 00117 pushElementFrame(const ElemTemplateElement* elem); 00118 00124 void 00125 popElementFrame(const ElemTemplateElement* elem); 00126 00134 void 00135 pushContextMarker(); 00136 00140 void 00141 popContextMarker(); 00142 00143 struct ParamsVectorEntry 00144 { 00145 ParamsVectorEntry() : 00146 m_qname(0), 00147 m_value(), 00148 m_variable(0) 00149 { 00150 } 00151 00152 ParamsVectorEntry( 00153 const XalanQName* qname, 00154 const XObjectPtr value) : 00155 m_qname(qname), 00156 m_value(value), 00157 m_variable(0) 00158 { 00159 } 00160 00161 ParamsVectorEntry( 00162 const XalanQName* qname, 00163 const ElemVariable* variable) : 00164 m_qname(qname), 00165 m_value(), 00166 m_variable(variable) 00167 { 00168 } 00169 00170 const XalanQName* m_qname; 00171 00172 XObjectPtr m_value; 00173 00174 const ElemVariable* m_variable; 00175 }; 00176 00177 #if defined(XALAN_NO_NAMESPACES) 00178 typedef vector<ParamsVectorEntry> ParamsVectorType; 00179 typedef vector<const ElemVariable*> RecursionGuardStackType; 00180 #else 00181 typedef std::vector<ParamsVectorEntry> ParamsVectorType; 00182 typedef std::vector<const ElemVariable*> RecursionGuardStackType; 00183 #endif 00184 00192 void 00193 pushParams( 00194 const ParamsVectorType& theParams, 00195 const ElemTemplateElement* targetTemplate); 00196 00207 const XObjectPtr 00208 getParamVariable( 00209 const XalanQName& qname, 00210 StylesheetExecutionContext& executionContext, 00211 bool& fNameFound) 00212 { 00213 return findXObject(qname, executionContext, true, false, fNameFound); 00214 } 00215 00227 const XObjectPtr 00228 getVariable( 00229 const XalanQName& qname, 00230 StylesheetExecutionContext& executionContext, 00231 bool& fNameFound) 00232 { 00233 return findXObject(qname, executionContext, false, true, fNameFound); 00234 } 00235 00245 void 00246 pushVariable( 00247 const XalanQName& name, 00248 const ElemVariable* var, 00249 const ElemTemplateElement* e); 00250 00260 void 00261 pushVariable( 00262 const XalanQName& name, 00263 const XObjectPtr& val, 00264 const ElemTemplateElement* e); 00265 00269 void 00270 start(); 00271 00275 void 00276 resetParams(); 00277 00281 void 00282 markGlobalStackFrame(); 00283 00287 void 00288 unmarkGlobalStackFrame(); 00289 00297 void 00298 setCurrentStackFrameIndex(int currentStackFrameIndex = -1) 00299 { 00300 if (currentStackFrameIndex == -1) 00301 m_currentStackFrameIndex = m_stack.size(); 00302 else 00303 m_currentStackFrameIndex = currentStackFrameIndex; 00304 } 00305 00312 int 00313 getCurrentStackFrameIndex() const 00314 { 00315 return m_currentStackFrameIndex; 00316 } 00317 00323 int 00324 getGlobalStackFrameIndex() const 00325 { 00326 return m_globalStackFrameIndex; 00327 } 00328 00329 class InvalidStackContextException : public XSLTProcessorException 00330 { 00331 public: 00332 00333 InvalidStackContextException(); 00334 00335 virtual 00336 ~InvalidStackContextException(); 00337 00338 private: 00339 00340 }; 00341 00342 class PushParamFunctor 00343 { 00344 public: 00345 00346 PushParamFunctor(VariablesStack& theVariablesStack) : 00347 m_variablesStack(theVariablesStack) 00348 { 00349 } 00350 00351 const void 00352 operator()(const ParamsVectorType::value_type& theEntry); 00353 00354 private: 00355 00356 VariablesStack& m_variablesStack; 00357 }; 00358 00359 private: 00360 00361 class StackEntry; 00362 00370 bool 00371 elementFrameAlreadyPushed(const ElemTemplateElement* elem) const; 00372 00378 void 00379 push(const StackEntry& theEntry); 00380 00384 void 00385 pop(); 00386 00392 const StackEntry& 00393 back() const 00394 { 00395 assert(m_stack.empty() == false); 00396 00397 return m_stack.back(); 00398 } 00399 00400 friend class CommitPushElementFrame; 00401 friend class EnsurePop; 00402 friend class PushParamFunctor; 00403 friend class SetAndRestoreForceGlobalSearch; 00404 00405 class XALAN_XSLT_EXPORT StackEntry 00406 { 00407 public: 00408 00413 enum eType { eContextMarker, 00414 eVariable, 00415 eParam, 00416 eActiveParam, 00417 eElementFrameMarker, 00418 eNextValue }; 00419 00423 explicit 00424 StackEntry(); 00425 00429 StackEntry( 00430 const XalanQName* name, 00431 const XObjectPtr& val, 00432 bool isParam = false); 00433 00437 StackEntry( 00438 const XalanQName* name, 00439 const ElemVariable* var, 00440 bool isParam = false); 00441 00445 StackEntry(const ElemTemplateElement* elem); 00446 00447 00451 StackEntry(const StackEntry& theSource); 00452 00456 ~StackEntry(); 00457 00463 eType 00464 getType() const 00465 { 00466 return m_type; 00467 } 00468 00474 const XalanQName* 00475 getName() const 00476 { 00477 return m_qname; 00478 } 00479 00485 const XObjectPtr& 00486 getValue() const 00487 { 00488 return m_value; 00489 } 00490 00496 void 00497 setValue(const XObjectPtr& theValue) 00498 { 00499 m_value = theValue; 00500 } 00501 00507 const ElemVariable* 00508 getVariable() const 00509 { 00510 return m_variable; 00511 } 00512 00513 void 00514 activate(); 00515 00516 void 00517 deactivate(); 00518 00524 const ElemTemplateElement* 00525 getElement() const 00526 { 00527 return m_element; 00528 } 00529 00530 StackEntry& 00531 operator=(const StackEntry& theRHS); 00532 00533 bool 00534 operator==(const StackEntry& theRHS) const; 00535 00536 private: 00537 00538 // Data members... 00539 eType m_type; 00540 00541 const XalanQName* m_qname; 00542 00543 XObjectPtr m_value; 00544 00545 const ElemVariable* m_variable; 00546 00547 const ElemTemplateElement* m_element; 00548 }; 00549 00550 #if defined(XALAN_NO_NAMESPACES) 00551 typedef vector<StackEntry> VariableStackStackType; 00552 #else 00553 typedef std::vector<StackEntry> VariableStackStackType; 00554 #endif 00555 00556 enum { eDefaultStackSize = 100 }; 00557 00558 00559 const XObjectPtr 00560 findXObject( 00561 const XalanQName& name, 00562 StylesheetExecutionContext& executionContext, 00563 bool fIsParam, 00564 bool fSearchGlobalSpace, 00565 bool& fNameFound); 00566 00567 StackEntry* 00568 findEntry( 00569 const XalanQName& name, 00570 bool fIsParam, 00571 bool fSearchGlobalSpace); 00572 00573 00574 VariableStackStackType m_stack; 00575 00576 int m_globalStackFrameIndex; 00577 00578 bool m_globalStackFrameMarked; 00579 00585 unsigned int m_currentStackFrameIndex; 00586 00592 RecursionGuardStackType m_guardStack; 00593 }; 00594 00595 00596 00597 #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.3 |
|