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/QName.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 QName* qname, 00154 const XObjectPtr value) : 00155 m_qname(qname), 00156 m_value(value), 00157 m_variable(0) 00158 { 00159 } 00160 00161 ParamsVectorEntry( 00162 const QName* qname, 00163 const ElemVariable* variable) : 00164 m_qname(qname), 00165 m_value(), 00166 m_variable(variable) 00167 { 00168 } 00169 00170 const QName* 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 #else 00180 typedef std::vector<ParamsVectorEntry> ParamsVectorType; 00181 #endif 00182 00190 void 00191 pushParams( 00192 const ParamsVectorType& theParams, 00193 const ElemTemplateElement* targetTemplate); 00194 00205 const XObjectPtr 00206 getParamVariable( 00207 const QName& qname, 00208 StylesheetExecutionContext& executionContext, 00209 bool& fNameFound) 00210 { 00211 return findXObject(qname, executionContext, true, false, fNameFound); 00212 } 00213 00223 const XObjectPtr 00224 getVariable( 00225 const QName& qname, 00226 StylesheetExecutionContext& executionContext, 00227 bool& fNameFound) 00228 { 00229 return findXObject(qname, executionContext, false, true, fNameFound); 00230 } 00231 00241 void 00242 pushVariable( 00243 const QName& name, 00244 const ElemVariable* var, 00245 const ElemTemplateElement* e); 00246 00256 void 00257 pushVariable( 00258 const QName& name, 00259 const XObjectPtr& val, 00260 const ElemTemplateElement* e); 00261 00265 void 00266 start(); 00267 00271 void 00272 resetParams(); 00273 00277 void 00278 markGlobalStackFrame(); 00279 00287 void 00288 setCurrentStackFrameIndex(int currentStackFrameIndex = -1) 00289 { 00290 if (currentStackFrameIndex == -1) 00291 m_currentStackFrameIndex = m_stack.size(); 00292 else 00293 m_currentStackFrameIndex = currentStackFrameIndex; 00294 } 00295 00302 int 00303 getCurrentStackFrameIndex() const 00304 { 00305 return m_currentStackFrameIndex; 00306 } 00307 00308 class InvalidStackContextException : public XSLTProcessorException 00309 { 00310 public: 00311 00312 InvalidStackContextException(); 00313 00314 virtual 00315 ~InvalidStackContextException(); 00316 00317 private: 00318 00319 }; 00320 00321 class PushParamFunctor 00322 { 00323 public: 00324 00325 PushParamFunctor(VariablesStack& theVariablesStack) : 00326 m_variablesStack(theVariablesStack) 00327 { 00328 } 00329 00330 const void 00331 operator()(const ParamsVectorType::value_type& theEntry); 00332 00333 private: 00334 00335 VariablesStack& m_variablesStack; 00336 }; 00337 00338 private: 00339 00340 class StackEntry; 00341 00349 bool 00350 elementFrameAlreadyPushed(const ElemTemplateElement* elem) const; 00351 00357 void 00358 push(const StackEntry& theEntry); 00359 00363 void 00364 pop(); 00365 00371 const StackEntry& 00372 back() const 00373 { 00374 assert(m_stack.empty() == false); 00375 00376 return m_stack.back(); 00377 } 00378 00379 friend class CommitPushElementFrame; 00380 friend class EnsurePop; 00381 friend class PushParamFunctor; 00382 friend class SetAndRestoreForceGlobalSearch; 00383 00384 class StackEntry 00385 { 00386 public: 00387 00392 enum eType { eContextMarker, 00393 eVariable, 00394 eParam, 00395 eActiveParam, 00396 eElementFrameMarker, 00397 eNextValue }; 00398 00402 explicit 00403 StackEntry(); 00404 00408 StackEntry( 00409 const QName* name, 00410 const XObjectPtr& val, 00411 bool isParam = false); 00412 00416 StackEntry( 00417 const QName* name, 00418 const ElemVariable* var, 00419 bool isParam = false); 00420 00424 StackEntry(const ElemTemplateElement* elem); 00425 00426 00430 StackEntry(const StackEntry& theSource); 00431 00435 ~StackEntry(); 00436 00442 eType 00443 getType() const 00444 { 00445 return m_type; 00446 } 00447 00453 const QName* 00454 getName() const 00455 { 00456 return m_qname; 00457 } 00458 00464 const XObjectPtr& 00465 getValue() const 00466 { 00467 return m_value; 00468 } 00469 00475 void 00476 setValue(const XObjectPtr& theValue) 00477 { 00478 m_value = theValue; 00479 } 00480 00486 const ElemVariable* 00487 getVariable() const 00488 { 00489 return m_variable; 00490 } 00491 00492 void 00493 activate(); 00494 00495 void 00496 deactivate(); 00497 00503 const ElemTemplateElement* 00504 getElement() const 00505 { 00506 return m_element; 00507 } 00508 00509 StackEntry& 00510 operator=(const StackEntry& theRHS); 00511 00512 bool 00513 operator==(const StackEntry& theRHS) const; 00514 00515 private: 00516 00517 // Data members... 00518 eType m_type; 00519 00520 const QName* m_qname; 00521 00522 XObjectPtr m_value; 00523 00524 const ElemVariable* m_variable; 00525 00526 const ElemTemplateElement* m_element; 00527 }; 00528 00529 #if defined(XALAN_NO_NAMESPACES) 00530 typedef vector<StackEntry> VariableStackStackType; 00531 #else 00532 typedef std::vector<StackEntry> VariableStackStackType; 00533 #endif 00534 00535 enum { eDefaultStackSize = 100 }; 00536 00537 00538 const XObjectPtr 00539 findXObject( 00540 const QName& name, 00541 StylesheetExecutionContext& executionContext, 00542 bool fIsParam, 00543 bool fSearchGlobalSpace, 00544 bool& fNameFound); 00545 00546 StackEntry* 00547 findEntry( 00548 const QName& name, 00549 bool fIsParam, 00550 bool fSearchGlobalSpace); 00551 00552 00553 VariableStackStackType m_stack; 00554 00555 int m_globalStackFrameIndex; 00556 00557 bool m_globalStackFrameMarked; 00558 00559 bool m_forceGlobalOnlySearch; 00560 00566 unsigned int m_currentStackFrameIndex; 00567 }; 00568 00569 00570 00571 #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++ XSL Transformer Version 1.1 |
|