Xalan-C++ API Documentation

The Xalan C++ XSLT Processor Version 1.8

Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

XPathExecutionContext.hpp

Go to the documentation of this file.
00001 /* 00002 * Copyright 1999-2004 The Apache Software Foundation. 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 #if !defined(XPATHEXECUTIONCONTEXT_HEADER_GUARD_1357924680) 00017 #define XPATHEXECUTIONCONTEXT_HEADER_GUARD_1357924680 00018 00019 00020 00021 // Base include file. Must be first. 00022 #include <xalanc/XPath/XPathDefinitions.hpp> 00023 00024 00025 00026 #include <cassert> 00027 #include <vector> 00028 00029 00030 00031 #include <xalanc/XalanDOM/XalanDOMString.hpp> 00032 00033 00034 00038 // Base class header file... 00039 #include <xalanc/PlatformSupport/ExecutionContext.hpp> 00040 00041 00042 00043 #include <xalanc/XPath/MutableNodeRefList.hpp> 00044 00045 00046 00047 XALAN_CPP_NAMESPACE_BEGIN 00048 00049 00050 00051 class XalanDecimalFormatSymbols; 00052 class PrefixResolver; 00053 class XalanQName; 00054 class XObject; 00055 class XObjectPtr; 00056 class XObjectFactory; 00057 class XalanDocument; 00058 class XalanElement; 00059 class XalanNode; 00060 class XalanText; 00061 00062 00063 00064 // 00065 // An abstract class which provides support for executing XPath functions 00066 // and extension functions. 00067 // 00068 00069 class XALAN_XPATH_EXPORT XPathExecutionContext : public ExecutionContext 00070 { 00071 public: 00072 00073 #if defined(XALAN_NO_STD_NAMESPACE) 00074 typedef vector<XObjectPtr> XObjectArgVectorType; 00075 #else 00076 typedef std::vector<XObjectPtr> XObjectArgVectorType; 00077 #endif 00078 00079 typedef NodeRefListBase::size_type size_type; 00080 00081 explicit 00082 XPathExecutionContext(XObjectFactory* theXObjectFactory = 0); 00083 00084 virtual 00085 ~XPathExecutionContext(); 00086 00091 virtual void 00092 reset() = 0; 00093 00099 virtual XalanNode* 00100 getCurrentNode() const = 0; 00101 00107 virtual void 00108 pushCurrentNode(XalanNode* theCurrentNode) = 0; 00109 00113 virtual void 00114 popCurrentNode() = 0; 00115 00116 class CurrentNodePushAndPop 00117 { 00118 public: 00119 00120 CurrentNodePushAndPop( 00121 XPathExecutionContext& theExecutionContext, 00122 XalanNode* theNewNode) : 00123 m_executionContext(theExecutionContext) 00124 { 00125 theExecutionContext.pushCurrentNode(theNewNode); 00126 } 00127 00128 ~CurrentNodePushAndPop() 00129 { 00130 m_executionContext.popCurrentNode(); 00131 } 00132 00133 private: 00134 00135 XPathExecutionContext& m_executionContext; 00136 }; 00137 00143 XObjectFactory& 00144 getXObjectFactory() const 00145 { 00146 assert(m_xobjectFactory != 0); 00147 00148 return *m_xobjectFactory; 00149 } 00150 00158 virtual bool 00159 isNodeAfter( 00160 const XalanNode& node1, 00161 const XalanNode& node2) const = 0; 00162 00168 virtual void 00169 pushContextNodeList(const NodeRefListBase& theList) = 0; 00170 00174 virtual void 00175 popContextNodeList() = 0; 00176 00177 class ContextNodeListPushAndPop 00178 { 00179 public: 00180 00181 ContextNodeListPushAndPop( 00182 XPathExecutionContext& theExecutionContext, 00183 const NodeRefListBase& theNodeList) : 00184 m_executionContext(theExecutionContext) 00185 { 00186 m_executionContext.pushContextNodeList(theNodeList); 00187 } 00188 00189 ~ContextNodeListPushAndPop() 00190 { 00191 m_executionContext.popContextNodeList(); 00192 } 00193 00194 private: 00195 00196 XPathExecutionContext& m_executionContext; 00197 }; 00198 00204 virtual const NodeRefListBase& 00205 getContextNodeList() const = 0; 00206 00207 /* 00208 * Get the count of nodes in the current context node list. 00209 * 00210 * @return length of list 00211 */ 00212 virtual size_type 00213 getContextNodeListLength() const = 0; 00214 00215 /* 00216 * Get the position of the node in the current context node list. 00217 * Note that this is 1-based indexing (XPath/XSLT-style), not 0-based. 00218 * Thus, 0 will be returned if the node was not found. 00219 * 00220 * @return position in list 00221 */ 00222 virtual size_type 00223 getContextNodeListPosition(const XalanNode& contextNode) const = 0; 00224 00232 virtual bool 00233 elementAvailable(const XalanQName& theQName) const = 0; 00234 00244 virtual bool 00245 elementAvailable( 00246 const XalanDOMString& theName, 00247 const LocatorType* locator) const = 0; 00248 00256 virtual bool 00257 functionAvailable(const XalanQName& theQName) const = 0; 00258 00267 virtual bool 00268 functionAvailable( 00269 const XalanDOMString& theName, 00270 const LocatorType* locator) const = 0; 00271 00282 virtual const XObjectPtr 00283 extFunction( 00284 const XalanDOMString& theNamespace, 00285 const XalanDOMString& functionName, 00286 XalanNode* context, 00287 const XObjectArgVectorType& argVec, 00288 const LocatorType* locator) = 0; 00289 00297 virtual XalanDocument* 00298 parseXML( 00299 const XalanDOMString& urlString, 00300 const XalanDOMString& base) const = 0; 00301 00307 virtual MutableNodeRefList* 00308 borrowMutableNodeRefList() = 0; 00309 00316 virtual bool 00317 returnMutableNodeRefList(MutableNodeRefList* theList) = 0; 00318 00319 class BorrowReturnMutableNodeRefList 00320 { 00321 public: 00322 00323 BorrowReturnMutableNodeRefList(XPathExecutionContext& executionContext) : 00324 m_xpathExecutionContext(&executionContext), 00325 m_mutableNodeRefList(executionContext.borrowMutableNodeRefList()) 00326 { 00327 assert(m_mutableNodeRefList != 0); 00328 } 00329 00330 // N.B. Non-const copy constructor semantics (like std::auto_ptr) 00331 BorrowReturnMutableNodeRefList(const BorrowReturnMutableNodeRefList& theSource) : 00332 m_xpathExecutionContext(theSource.m_xpathExecutionContext), 00333 m_mutableNodeRefList(theSource.m_mutableNodeRefList) 00334 { 00335 assert(m_mutableNodeRefList != 0); 00336 00337 ((BorrowReturnMutableNodeRefList&)theSource).m_mutableNodeRefList = 0; 00338 } 00339 00340 ~BorrowReturnMutableNodeRefList() 00341 { 00342 release(); 00343 } 00344 00345 MutableNodeRefList& 00346 operator*() const 00347 { 00348 assert(m_mutableNodeRefList != 0); 00349 00350 return *m_mutableNodeRefList; 00351 } 00352 00353 MutableNodeRefList* 00354 get() const 00355 { 00356 return m_mutableNodeRefList; 00357 } 00358 00359 MutableNodeRefList* 00360 operator->() const 00361 { 00362 return get(); 00363 } 00364 00365 void 00366 release() 00367 { 00368 assert(m_xpathExecutionContext != 0); 00369 00370 if (m_mutableNodeRefList != 0) 00371 { 00372 m_xpathExecutionContext->returnMutableNodeRefList(m_mutableNodeRefList); 00373 00374 m_mutableNodeRefList = 0; 00375 } 00376 } 00377 00378 BorrowReturnMutableNodeRefList 00379 clone() const 00380 { 00381 assert(m_xpathExecutionContext != 0); 00382 00383 BorrowReturnMutableNodeRefList theResult(*m_xpathExecutionContext); 00384 00385 *theResult = *m_mutableNodeRefList; 00386 00387 return theResult; 00388 } 00389 00390 // N.B. Non-const assignment operator semantics. 00391 BorrowReturnMutableNodeRefList& 00392 operator=(BorrowReturnMutableNodeRefList& theRHS) 00393 { 00394 release(); 00395 00396 m_xpathExecutionContext = theRHS.m_xpathExecutionContext; 00397 00398 m_mutableNodeRefList = theRHS.m_mutableNodeRefList; 00399 00400 theRHS.m_mutableNodeRefList = 0; 00401 00402 return *this; 00403 } 00404 00405 private: 00406 00407 XPathExecutionContext* m_xpathExecutionContext; 00408 00409 MutableNodeRefList* m_mutableNodeRefList; 00410 }; 00411 00417 virtual XalanDOMString& 00418 getCachedString() = 0; 00419 00427 virtual bool 00428 releaseCachedString(XalanDOMString& theString) = 0; 00429 00430 class GetAndReleaseCachedString 00431 { 00432 public: 00433 00434 GetAndReleaseCachedString(XPathExecutionContext& theExecutionContext) : 00435 m_executionContext(&theExecutionContext), 00436 m_string(&theExecutionContext.getCachedString()) 00437 { 00438 } 00439 00440 // Note non-const copy semantics... 00441 GetAndReleaseCachedString(GetAndReleaseCachedString& theSource) : 00442 m_executionContext(theSource.m_executionContext), 00443 m_string(theSource.m_string) 00444 { 00445 theSource.m_string = 0; 00446 } 00447 00448 ~GetAndReleaseCachedString() 00449 { 00450 if (m_string != 0) 00451 { 00452 m_executionContext->releaseCachedString(*m_string); 00453 } 00454 } 00455 00456 XalanDOMString& 00457 get() const 00458 { 00459 assert(m_string != 0); 00460 00461 return *m_string; 00462 } 00463 00464 XPathExecutionContext& 00465 getExecutionContext() const 00466 { 00467 return *m_executionContext; 00468 } 00469 00470 private: 00471 00472 // Not implemented... 00473 GetAndReleaseCachedString& 00474 operator=(const GetAndReleaseCachedString&); 00475 00476 00477 // Data members... 00478 XPathExecutionContext* m_executionContext; 00479 00480 XalanDOMString* m_string; 00481 }; 00482 00488 virtual MutableNodeRefList* 00489 createMutableNodeRefList() const = 0; 00490 00501 virtual void 00502 getNodeSetByKey( 00503 XalanDocument* doc, 00504 const XalanQName& qname, 00505 const XalanDOMString& ref, 00506 MutableNodeRefList& nodelist) = 0; 00507 00520 virtual void 00521 getNodeSetByKey( 00522 XalanDocument* doc, 00523 const XalanDOMString& name, 00524 const XalanDOMString& ref, 00525 const LocatorType* locator, 00526 MutableNodeRefList& nodelist) = 0; 00527 00535 virtual const XObjectPtr 00536 getVariable( 00537 const XalanQName& name, 00538 const LocatorType* locator = 0) = 0; 00539 00545 virtual const PrefixResolver* 00546 getPrefixResolver() const = 0; 00547 00553 virtual void 00554 setPrefixResolver(const PrefixResolver* thePrefixResolver) = 0; 00555 00556 class PrefixResolverSetAndRestore 00557 { 00558 public: 00559 00560 PrefixResolverSetAndRestore( 00561 XPathExecutionContext& theExecutionContext, 00562 const PrefixResolver* theResolver) : 00563 m_executionContext(theExecutionContext), 00564 m_savedResolver(theExecutionContext.getPrefixResolver()) 00565 { 00566 m_executionContext.setPrefixResolver(theResolver); 00567 } 00568 00569 PrefixResolverSetAndRestore( 00570 XPathExecutionContext& theExecutionContext, 00571 const PrefixResolver* theOldResolver, 00572 const PrefixResolver* theNewResolver) : 00573 m_executionContext(theExecutionContext), 00574 m_savedResolver(theOldResolver) 00575 { 00576 m_executionContext.setPrefixResolver(theNewResolver); 00577 } 00578 00579 ~PrefixResolverSetAndRestore() 00580 { 00581 m_executionContext.setPrefixResolver(m_savedResolver); 00582 } 00583 00584 private: 00585 00586 XPathExecutionContext& m_executionContext; 00587 const PrefixResolver* const m_savedResolver; 00588 }; 00589 00596 virtual const XalanDOMString* 00597 getNamespaceForPrefix(const XalanDOMString& prefix) const = 0; 00598 00606 virtual XalanDOMString 00607 findURIFromDoc(const XalanDocument* owner) const = 0; 00608 00619 virtual const XalanDOMString& 00620 getUnparsedEntityURI( 00621 const XalanDOMString& theName, 00622 const XalanDocument& theDocument) const = 0; 00623 00634 virtual bool 00635 shouldStripSourceNode(const XalanText& node) = 0; 00636 00643 virtual XalanDocument* 00644 getSourceDocument(const XalanDOMString& theURI) const = 0; 00645 00652 virtual void 00653 setSourceDocument( 00654 const XalanDOMString& theURI, 00655 XalanDocument* theDocument) = 0; 00656 00666 virtual void formatNumber( 00667 double number, 00668 const XalanDOMString& pattern, 00669 XalanDOMString& theResult, 00670 const XalanNode* context = 0, 00671 const LocatorType* locator = 0) = 0; 00672 00684 virtual void formatNumber( 00685 double number, 00686 const XalanDOMString& pattern, 00687 const XalanDOMString& dfsName, 00688 XalanDOMString& theResult, 00689 const XalanNode* context = 0, 00690 const LocatorType* locator = 0) = 0; 00691 00692 // These interfaces are inherited from ExecutionContext... 00693 00694 virtual void 00695 error( 00696 const XalanDOMString& msg, 00697 const XalanNode* sourceNode = 0, 00698 const LocatorType* locator = 0) const = 0; 00699 00700 virtual void 00701 error( 00702 const char* msg, 00703 const XalanNode* sourceNode = 0, 00704 const LocatorType* locator = 0) const = 0; 00705 00706 virtual void 00707 warn( 00708 const XalanDOMString& msg, 00709 const XalanNode* sourceNode = 0, 00710 const LocatorType* locator = 0) const = 0; 00711 00712 virtual void 00713 warn( 00714 const char* msg, 00715 const XalanNode* sourceNode = 0, 00716 const LocatorType* locator = 0) const = 0; 00717 00718 virtual void 00719 message( 00720 const XalanDOMString& msg, 00721 const XalanNode* sourceNode = 0, 00722 const LocatorType* locator = 0) const = 0; 00723 00724 virtual void 00725 message( 00726 const char* msg, 00727 const XalanNode* sourceNode = 0, 00728 const LocatorType* locator = 0) const = 0; 00729 00730 protected: 00731 00732 XObjectFactory* m_xobjectFactory; 00733 }; 00734 00735 00736 00737 XALAN_CPP_NAMESPACE_END 00738 00739 00740 00741 #endif // XPATHEXECUTIONCONTEXT_HEADER_GUARD_1357924680

Interpreting class diagrams

Doxygen and GraphViz are used to generate this API documentation from the Xalan-C header files.

Xalan-C++ XSLT Processor Version 1.8
Copyright © 1999-2004 The Apache Software Foundation. All Rights Reserved.