00001 /* 00002 * The Apache Software License, Version 1.1 00003 * 00004 * 00005 * Copyright (c) 1999 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 * @author <a href="mailto:david_n_bertoni@lotus.com">David N. Bertoni</a> 00058 */ 00059 #if !defined(XPATHEXECUTIONCONTEXT_HEADER_GUARD_1357924680) 00060 #define XPATHEXECUTIONCONTEXT_HEADER_GUARD_1357924680 00061 00062 00063 00064 // Base include file. Must be first. 00065 #include <XPath/XPathDefinitions.hpp> 00066 00067 00068 00069 #include <cassert> 00070 #include <vector> 00071 00072 00073 00074 #include <XalanDOM/XalanDOMString.hpp> 00075 00076 00077 00078 // Base class header file... 00079 #include <PlatformSupport/ExecutionContext.hpp> 00080 00081 00082 00083 #include <XPath/MutableNodeRefList.hpp> 00084 #include <XPath/ResultTreeFragBase.hpp> 00085 00086 00087 00088 class XalanDecimalFormatSymbols; 00089 class PrefixResolver; 00090 class XalanQName; 00091 class XLocator; 00092 class XMLURL; 00093 class XObject; 00094 class XObjectPtr; 00095 class XObjectFactory; 00096 class XalanDocument; 00097 class XalanElement; 00098 class XalanNode; 00099 class XalanText; 00100 00101 00102 00103 // 00104 // An abstract class which provides support for executing XPath functions 00105 // and extension functions. 00106 // 00107 00108 class XALAN_XPATH_EXPORT XPathExecutionContext : public ExecutionContext 00109 { 00110 public: 00111 00112 #if defined(XALAN_NO_NAMESPACES) 00113 typedef vector<XObjectPtr> XObjectArgVectorType; 00114 #else 00115 typedef std::vector<XObjectPtr> XObjectArgVectorType; 00116 #endif 00117 00118 explicit 00119 XPathExecutionContext(); 00120 00121 virtual 00122 ~XPathExecutionContext(); 00123 00128 virtual void 00129 reset() = 0; 00130 00136 virtual XalanNode* 00137 getCurrentNode() const = 0; 00138 00144 virtual void 00145 setCurrentNode(XalanNode* theCurrentNode) = 0; 00146 00147 class CurrentNodeSetAndRestore 00148 { 00149 public: 00150 00151 CurrentNodeSetAndRestore( 00152 XPathExecutionContext& theExecutionContext, 00153 XalanNode* theNode) : 00154 m_executionContext(theExecutionContext), 00155 m_savedNode(theExecutionContext.getCurrentNode()) 00156 { 00157 m_executionContext.setCurrentNode(theNode); 00158 } 00159 00160 ~CurrentNodeSetAndRestore() 00161 { 00162 m_executionContext.setCurrentNode(m_savedNode); 00163 } 00164 00165 private: 00166 00167 XPathExecutionContext& m_executionContext; 00168 XalanNode* const m_savedNode; 00169 }; 00170 00176 virtual XObjectFactory& 00177 getXObjectFactory() const = 0; 00178 00186 virtual XObjectPtr 00187 createNodeSet(XalanNode& theNode) = 0; 00188 00196 virtual bool 00197 isNodeAfter( 00198 const XalanNode& node1, 00199 const XalanNode& node2) const = 0; 00200 00206 virtual const NodeRefListBase& 00207 getContextNodeList() const = 0; 00208 00214 virtual void 00215 setContextNodeList(const NodeRefListBase& theList) = 0; 00216 00217 class ContextNodeListSetAndRestore 00218 { 00219 public: 00220 00221 ContextNodeListSetAndRestore( 00222 XPathExecutionContext& theExecutionContext, 00223 const NodeRefListBase& theNodeList) : 00224 m_executionContext(theExecutionContext), 00225 m_savedNodeList(theExecutionContext.getContextNodeList()) 00226 { 00227 m_executionContext.setContextNodeList(theNodeList); 00228 } 00229 00230 ~ContextNodeListSetAndRestore() 00231 { 00232 m_executionContext.setContextNodeList(m_savedNodeList); 00233 } 00234 00235 private: 00236 00237 XPathExecutionContext& m_executionContext; 00238 const NodeRefListBase& m_savedNodeList; 00239 }; 00240 00241 /* 00242 * Get the count of nodes in the current context node list. 00243 * 00244 * @return length of list 00245 */ 00246 virtual unsigned int 00247 getContextNodeListLength() const = 0; 00248 00249 /* 00250 * Get the position of the node in the current context node list. 00251 * Note that this is 1-based indexing (XPath/XSLT-style), not 0-based. 00252 * Thus, 0 will be returned if the node was not found. 00253 * 00254 * @return position in list 00255 */ 00256 virtual unsigned int 00257 getContextNodeListPosition(const XalanNode& contextNode) const = 0; 00258 00266 virtual bool 00267 elementAvailable( 00268 const XalanDOMString& theNamespace, 00269 const XalanDOMString& elementName) const = 0; 00270 00280 virtual bool 00281 functionAvailable( 00282 const XalanDOMString& theNamespace, 00283 const XalanDOMString& functionName) const = 0; 00284 00293 virtual const XObjectPtr 00294 extFunction( 00295 const XalanDOMString& theNamespace, 00296 const XalanDOMString& functionName, 00297 XalanNode* context, 00298 const XObjectArgVectorType& argVec) = 0; 00299 00307 virtual XalanDocument* 00308 parseXML( 00309 const XalanDOMString& urlString, 00310 const XalanDOMString& base) const = 0; 00311 00317 virtual MutableNodeRefList* 00318 borrowMutableNodeRefList() = 0; 00319 00326 virtual bool 00327 returnMutableNodeRefList(MutableNodeRefList* theList) = 0; 00328 00329 class BorrowReturnMutableNodeRefList 00330 { 00331 public: 00332 00333 BorrowReturnMutableNodeRefList(XPathExecutionContext& executionContext) : 00334 m_xpathExecutionContext(&executionContext), 00335 m_mutableNodeRefList(executionContext.borrowMutableNodeRefList()) 00336 { 00337 assert(m_mutableNodeRefList != 0); 00338 } 00339 00340 // N.B. Non-const copy constructor semantics (like std::auto_ptr) 00341 BorrowReturnMutableNodeRefList(const BorrowReturnMutableNodeRefList& theSource) : 00342 m_xpathExecutionContext(theSource.m_xpathExecutionContext), 00343 m_mutableNodeRefList(theSource.m_mutableNodeRefList) 00344 { 00345 assert(m_mutableNodeRefList != 0); 00346 00347 ((BorrowReturnMutableNodeRefList&)theSource).m_mutableNodeRefList = 0; 00348 } 00349 00350 ~BorrowReturnMutableNodeRefList() 00351 { 00352 release(); 00353 } 00354 00355 MutableNodeRefList& 00356 operator*() const 00357 { 00358 assert(m_mutableNodeRefList != 0); 00359 00360 return *m_mutableNodeRefList; 00361 } 00362 00363 MutableNodeRefList* 00364 get() const 00365 { 00366 return m_mutableNodeRefList; 00367 } 00368 00369 MutableNodeRefList* 00370 operator->() const 00371 { 00372 return get(); 00373 } 00374 00375 void 00376 release() 00377 { 00378 assert(m_xpathExecutionContext != 0); 00379 00380 if (m_mutableNodeRefList != 0) 00381 { 00382 m_xpathExecutionContext->returnMutableNodeRefList(m_mutableNodeRefList); 00383 00384 m_mutableNodeRefList = 0; 00385 } 00386 } 00387 00388 BorrowReturnMutableNodeRefList 00389 clone() const 00390 { 00391 assert(m_xpathExecutionContext != 0); 00392 00393 BorrowReturnMutableNodeRefList theResult(*m_xpathExecutionContext); 00394 00395 *theResult = *m_mutableNodeRefList; 00396 00397 return theResult; 00398 } 00399 00400 // N.B. Non-const assignment operator semantics. 00401 BorrowReturnMutableNodeRefList& 00402 operator=(BorrowReturnMutableNodeRefList& theRHS) 00403 { 00404 release(); 00405 00406 m_xpathExecutionContext = theRHS.m_xpathExecutionContext; 00407 00408 m_mutableNodeRefList = theRHS.m_mutableNodeRefList; 00409 00410 theRHS.m_mutableNodeRefList = 0; 00411 00412 return *this; 00413 } 00414 00415 private: 00416 00417 XPathExecutionContext* m_xpathExecutionContext; 00418 00419 MutableNodeRefList* m_mutableNodeRefList; 00420 }; 00421 00422 virtual XalanDOMString& 00423 getCachedString() = 0; 00424 00425 virtual bool 00426 releaseCachedString(XalanDOMString& theString) = 0; 00427 00428 class GetAndReleaseCachedString 00429 { 00430 public: 00431 00432 GetAndReleaseCachedString(XPathExecutionContext& theExecutionContext) : 00433 m_executionContext(&theExecutionContext), 00434 m_string(&theExecutionContext.getCachedString()) 00435 { 00436 } 00437 00438 // Note non-const copy semantics... 00439 GetAndReleaseCachedString(GetAndReleaseCachedString& theSource) : 00440 m_executionContext(theSource.m_executionContext), 00441 m_string(theSource.m_string) 00442 { 00443 theSource.m_string = 0; 00444 } 00445 00446 ~GetAndReleaseCachedString() 00447 { 00448 if (m_string != 0) 00449 { 00450 m_executionContext->releaseCachedString(*m_string); 00451 } 00452 } 00453 00454 XalanDOMString& 00455 get() const 00456 { 00457 assert(m_string != 0); 00458 00459 return *m_string; 00460 } 00461 00462 XPathExecutionContext& 00463 getExecutionContext() const 00464 { 00465 return *m_executionContext; 00466 } 00467 00468 private: 00469 00470 // Not implemented... 00471 GetAndReleaseCachedString& 00472 operator=(const GetAndReleaseCachedString&); 00473 00474 00475 // Data members... 00476 XPathExecutionContext* m_executionContext; 00477 00478 XalanDOMString* m_string; 00479 }; 00480 00486 virtual ResultTreeFragBase* 00487 borrowResultTreeFrag() = 0; 00488 00495 virtual bool 00496 returnResultTreeFrag(ResultTreeFragBase* theResultTreeFragBase) = 0; 00497 00498 00499 class BorrowReturnResultTreeFrag 00500 { 00501 public: 00502 00503 BorrowReturnResultTreeFrag(XPathExecutionContext& executionContext) : 00504 m_xpathExecutionContext(&executionContext), 00505 m_resultTreeFrag(executionContext.borrowResultTreeFrag()) 00506 { 00507 assert(m_resultTreeFrag != 0); 00508 } 00509 00510 // N.B. Non-const copy constructor semantics (like std::auto_ptr) 00511 BorrowReturnResultTreeFrag(const BorrowReturnResultTreeFrag& theSource) : 00512 m_xpathExecutionContext(theSource.m_xpathExecutionContext), 00513 m_resultTreeFrag(theSource.m_resultTreeFrag) 00514 { 00515 assert(m_resultTreeFrag != 0); 00516 00517 ((BorrowReturnResultTreeFrag&)theSource).m_resultTreeFrag = 0; 00518 } 00519 00520 ~BorrowReturnResultTreeFrag() 00521 { 00522 if (m_resultTreeFrag != 0) 00523 { 00524 if (m_xpathExecutionContext->returnResultTreeFrag(m_resultTreeFrag) == false) 00525 { 00526 delete m_resultTreeFrag; 00527 } 00528 } 00529 } 00530 00531 // N.B. Non-const assignment operator semantics. 00532 BorrowReturnResultTreeFrag& 00533 operator=(BorrowReturnResultTreeFrag& theRHS) 00534 { 00535 release(); 00536 00537 m_xpathExecutionContext = theRHS.m_xpathExecutionContext; 00538 00539 m_resultTreeFrag = theRHS.m_resultTreeFrag; 00540 00541 theRHS.m_resultTreeFrag = 0; 00542 00543 return *this; 00544 } 00545 00546 ResultTreeFragBase& 00547 operator*() const 00548 { 00549 return *m_resultTreeFrag; 00550 } 00551 00552 ResultTreeFragBase* 00553 get() const 00554 { 00555 return m_resultTreeFrag; 00556 } 00557 00558 ResultTreeFragBase* 00559 operator->() const 00560 { 00561 return get(); 00562 } 00563 00564 void 00565 release() 00566 { 00567 assert(m_xpathExecutionContext != 0); 00568 00569 if (m_resultTreeFrag != 0) 00570 { 00571 m_xpathExecutionContext->returnResultTreeFrag(m_resultTreeFrag); 00572 00573 m_resultTreeFrag = 0; 00574 } 00575 } 00576 00577 BorrowReturnResultTreeFrag 00578 clone(bool deep = false) const 00579 { 00580 assert(m_xpathExecutionContext != 0); 00581 00582 BorrowReturnResultTreeFrag theResult( 00583 *m_xpathExecutionContext, 00584 m_resultTreeFrag->clone(deep)); 00585 00586 return theResult; 00587 } 00588 00589 private: 00590 00591 BorrowReturnResultTreeFrag( 00592 XPathExecutionContext& executionContext, 00593 ResultTreeFragBase* resultTreeFrag) : 00594 m_xpathExecutionContext(&executionContext), 00595 m_resultTreeFrag(resultTreeFrag) 00596 { 00597 assert(m_resultTreeFrag != 0); 00598 } 00599 00600 // Data members... 00601 XPathExecutionContext* m_xpathExecutionContext; 00602 00603 ResultTreeFragBase* m_resultTreeFrag; 00604 }; 00605 00606 friend class BorrowReturnResultTreeFrag; 00607 00613 virtual MutableNodeRefList* 00614 createMutableNodeRefList() const = 0; 00615 00627 virtual void 00628 getNodeSetByKey( 00629 XalanNode* doc, 00630 const XalanDOMString& name, 00631 const XalanDOMString& ref, 00632 const PrefixResolver& resolver, 00633 MutableNodeRefList& nodelist) = 0; 00634 00642 virtual const XObjectPtr 00643 getVariable(const XalanQName& name) = 0; 00644 00650 virtual const PrefixResolver* 00651 getPrefixResolver() const = 0; 00652 00658 virtual void 00659 setPrefixResolver(const PrefixResolver* thePrefixResolver) = 0; 00660 00661 class PrefixResolverSetAndRestore 00662 { 00663 public: 00664 00665 PrefixResolverSetAndRestore( 00666 XPathExecutionContext& theExecutionContext, 00667 const PrefixResolver* theResolver) : 00668 m_executionContext(theExecutionContext), 00669 m_savedResolver(theExecutionContext.getPrefixResolver()) 00670 { 00671 m_executionContext.setPrefixResolver(theResolver); 00672 } 00673 00674 PrefixResolverSetAndRestore( 00675 XPathExecutionContext& theExecutionContext, 00676 const PrefixResolver* theOldResolver, 00677 const PrefixResolver* theNewResolver) : 00678 m_executionContext(theExecutionContext), 00679 m_savedResolver(theOldResolver) 00680 { 00681 m_executionContext.setPrefixResolver(theNewResolver); 00682 } 00683 00684 ~PrefixResolverSetAndRestore() 00685 { 00686 m_executionContext.setPrefixResolver(m_savedResolver); 00687 } 00688 00689 private: 00690 00691 XPathExecutionContext& m_executionContext; 00692 const PrefixResolver* const m_savedResolver; 00693 }; 00694 00701 virtual const XalanDOMString* 00702 getNamespaceForPrefix(const XalanDOMString& prefix) const = 0; 00703 00711 virtual XalanDOMString 00712 findURIFromDoc(const XalanDocument* owner) const = 0; 00713 00719 virtual XalanDocument* 00720 getDOMFactory() const = 0; 00721 00732 virtual const XalanDOMString& 00733 getUnparsedEntityURI( 00734 const XalanDOMString& theName, 00735 const XalanDocument& theDocument) const = 0; 00736 00747 virtual bool 00748 shouldStripSourceNode(const XalanNode& node) = 0; 00749 00757 virtual bool 00758 getThrowFoundIndex() const = 0; 00759 00767 virtual void 00768 setThrowFoundIndex(bool fThrow) = 0; 00769 00770 virtual XalanDocument* 00771 getSourceDocument(const XalanDOMString& theURI) const = 0; 00772 00779 virtual void 00780 setSourceDocument( 00781 const XalanDOMString& theURI, 00782 XalanDocument* theDocument) = 0; 00783 00784 00792 virtual const XalanDecimalFormatSymbols* 00793 getDecimalFormatSymbols(const XalanDOMString& name) = 0; 00794 00795 // These interfaces are inherited from ExecutionContext... 00796 00797 virtual void 00798 error( 00799 const XalanDOMString& msg, 00800 const XalanNode* sourceNode = 0, 00801 const XalanNode* styleNode = 0) const = 0; 00802 00803 virtual void 00804 error( 00805 const XalanDOMString& msg, 00806 const XalanNode* sourceNode, 00807 const Locator* locator) const = 0; 00808 00809 virtual void 00810 error( 00811 const char* msg, 00812 const XalanNode* sourceNode = 0, 00813 const XalanNode* styleNode = 0) const = 0; 00814 00815 virtual void 00816 error( 00817 const char* msg, 00818 const XalanNode* sourceNode, 00819 const Locator* locator) const = 0; 00820 00821 virtual void 00822 warn( 00823 const XalanDOMString& msg, 00824 const XalanNode* sourceNode = 0, 00825 const XalanNode* styleNode = 0) const = 0; 00826 00827 virtual void 00828 warn( 00829 const XalanDOMString& msg, 00830 const XalanNode* sourceNode, 00831 const Locator* locator) const = 0; 00832 00833 virtual void 00834 warn( 00835 const char* msg, 00836 const XalanNode* sourceNode = 0, 00837 const XalanNode* styleNode = 0) const = 0; 00838 00839 virtual void 00840 warn( 00841 const char* msg, 00842 const XalanNode* sourceNode, 00843 const Locator* locator) const = 0; 00844 00845 virtual void 00846 message( 00847 const XalanDOMString& msg, 00848 const XalanNode* sourceNode = 0, 00849 const XalanNode* styleNode = 0) const = 0; 00850 00851 virtual void 00852 message( 00853 const XalanDOMString& msg, 00854 const XalanNode* sourceNode, 00855 const Locator* locator) const = 0; 00856 00857 virtual void 00858 message( 00859 const char* msg, 00860 const XalanNode* sourceNode = 0, 00861 const XalanNode* styleNode = 0) const = 0; 00862 00863 virtual void 00864 message( 00865 const char* msg, 00866 const XalanNode* sourceNode, 00867 const Locator* locator) const = 0; 00868 }; 00869 00870 00871 00872 #endif // XPATHEXECUTIONCONTEXT_HEADER_GUARD_1357924680
Doxygen and GraphViz are used to generate this API documentation from the Xalan-C header files.
![]() |
Xalan-C++ XSL Transformer Version 1.1 |
|