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/Function.hpp> 00084 #include <XPath/MutableNodeRefList.hpp> 00085 00086 00087 00088 class XalanDecimalFormatSymbols; 00089 class PrefixResolver; 00090 class QName; 00091 class XLocator; 00092 class XMLURL; 00093 class XObject; 00094 class XObjectFactory; 00095 class XalanDocument; 00096 class XalanElement; 00097 class XalanNode; 00098 class XalanText; 00099 00100 00101 00102 // 00103 // An abstract class which provides support for executing XPath functions 00104 // and extension functions. 00105 // 00106 00107 class XALAN_XPATH_EXPORT XPathExecutionContext : public ExecutionContext 00108 { 00109 public: 00110 00111 typedef Function::XObjectArgVectorType XObjectArgVectorType; 00112 00113 explicit 00114 XPathExecutionContext(); 00115 00116 virtual 00117 ~XPathExecutionContext(); 00118 00123 virtual void 00124 reset() = 0; 00125 00131 virtual XalanNode* 00132 getCurrentNode() const = 0; 00133 00139 virtual void 00140 setCurrentNode(XalanNode* theCurrentNode) = 0; 00141 00142 class CurrentNodeSetAndRestore 00143 { 00144 public: 00145 00146 CurrentNodeSetAndRestore( 00147 XPathExecutionContext& theExecutionContext, 00148 XalanNode* theNode) : 00149 m_executionContext(theExecutionContext), 00150 m_savedNode(theExecutionContext.getCurrentNode()) 00151 { 00152 m_executionContext.setCurrentNode(theNode); 00153 } 00154 00155 ~CurrentNodeSetAndRestore() 00156 { 00157 m_executionContext.setCurrentNode(m_savedNode); 00158 } 00159 00160 private: 00161 00162 XPathExecutionContext& m_executionContext; 00163 XalanNode* const m_savedNode; 00164 }; 00165 00171 virtual XObjectFactory& 00172 getXObjectFactory() const = 0; 00173 00181 virtual XObject* 00182 createNodeSet(XalanNode& theNode) = 0; 00183 00191 virtual bool 00192 isIgnorableWhitespace(const XalanText& node) const = 0; 00193 00200 virtual XalanDOMString 00201 getNamespaceOfNode(const XalanNode& n) const = 0; 00202 00211 virtual XalanDOMString 00212 getNameOfNode(const XalanNode& n) const = 0; 00213 00220 virtual XalanDOMString 00221 getLocalNameOfNode(const XalanNode& n) const = 0; 00222 00229 virtual XalanNode* 00230 getParentOfNode(const XalanNode& n) const = 0; 00231 00239 virtual bool 00240 isNodeAfter( 00241 const XalanNode& node1, 00242 const XalanNode& node2) const = 0; 00243 00251 virtual XalanDOMString 00252 getNodeData(const XalanNode& n) const = 0; 00253 00261 virtual XalanElement* 00262 getElementByID( 00263 const XalanDOMString& id, 00264 const XalanDocument& doc) const = 0; 00265 00271 virtual const NodeRefListBase& 00272 getContextNodeList() const = 0; 00273 00279 virtual void 00280 setContextNodeList(const NodeRefListBase& theList) = 0; 00281 00282 class ContextNodeListSetAndRestore 00283 { 00284 public: 00285 00286 ContextNodeListSetAndRestore( 00287 XPathExecutionContext& theExecutionContext, 00288 const NodeRefListBase& theNodeList) : 00289 m_executionContext(theExecutionContext), 00290 m_savedNodeList(theExecutionContext.getContextNodeList()) 00291 { 00292 m_executionContext.setContextNodeList(theNodeList); 00293 } 00294 00295 ~ContextNodeListSetAndRestore() 00296 { 00297 m_executionContext.setContextNodeList(m_savedNodeList); 00298 } 00299 00300 private: 00301 00302 XPathExecutionContext& m_executionContext; 00303 const NodeRefListBase& m_savedNodeList; 00304 }; 00305 00306 /* 00307 * Get the count of nodes in the current context node list. 00308 * 00309 * @return length of list 00310 */ 00311 virtual unsigned int 00312 getContextNodeListLength() const = 0; 00313 00314 /* 00315 * Get the position of the node in the current context node list. 00316 * Note that this is 1-based indexing (XPath/XSLT-style), not 0-based. 00317 * Thus, 0 will be returned if the node was not found. 00318 * 00319 * @return position in list 00320 */ 00321 virtual unsigned int 00322 getContextNodeListPosition(const XalanNode& contextNode) const = 0; 00323 00331 virtual bool 00332 elementAvailable( 00333 const XalanDOMString& theNamespace, 00334 const XalanDOMString& elementName) const = 0; 00335 00345 virtual bool 00346 functionAvailable( 00347 const XalanDOMString& theNamespace, 00348 const XalanDOMString& functionName) const = 0; 00349 00358 virtual const XObject* 00359 extFunction( 00360 const XalanDOMString& theNamespace, 00361 const XalanDOMString& functionName, 00362 XalanNode* context, 00363 const XObjectArgVectorType& argVec) = 0; 00364 00372 virtual XObjectArgVectorType& 00373 pushArgVector() = 0; 00374 00378 virtual void 00379 popArgVector() = 0; 00380 00381 class PushPopArgVector 00382 { 00383 public: 00384 00385 PushPopArgVector(XPathExecutionContext& executionContext) : 00386 m_xpathExecutionContext(executionContext), 00387 m_argVector(executionContext.pushArgVector()) 00388 { 00389 } 00390 00391 ~PushPopArgVector() 00392 { 00393 m_xpathExecutionContext.popArgVector(); 00394 } 00395 00396 XObjectArgVectorType& 00397 getVector() 00398 { 00399 return m_argVector; 00400 } 00401 00402 private: 00403 00404 XPathExecutionContext& m_xpathExecutionContext; 00405 00406 XObjectArgVectorType& m_argVector; 00407 }; 00408 00416 virtual XLocator* 00417 getXLocatorFromNode(const XalanNode* node) const = 0; 00418 00426 virtual void 00427 associateXLocatorToNode( 00428 const XalanNode* node, 00429 XLocator* xlocator) = 0; 00430 00438 virtual XalanDocument* 00439 parseXML( 00440 const XalanDOMString& urlString, 00441 const XalanDOMString& base) const = 0; 00442 00448 virtual MutableNodeRefList* 00449 borrowMutableNodeRefList() = 0; 00450 00457 virtual bool 00458 returnMutableNodeRefList(MutableNodeRefList* theList) = 0; 00459 00460 class BorrowReturnMutableNodeRefList 00461 { 00462 public: 00463 00464 BorrowReturnMutableNodeRefList(XPathExecutionContext& executionContext) : 00465 m_xpathExecutionContext(executionContext), 00466 m_mutableNodeRefList(executionContext.borrowMutableNodeRefList()) 00467 { 00468 assert(m_mutableNodeRefList != 0); 00469 } 00470 00471 // N.B. Non-const copy constructor semantics (like std::auto_ptr) 00472 BorrowReturnMutableNodeRefList(const BorrowReturnMutableNodeRefList& theSource) : 00473 m_xpathExecutionContext(theSource.m_xpathExecutionContext), 00474 m_mutableNodeRefList(theSource.m_mutableNodeRefList) 00475 { 00476 assert(m_mutableNodeRefList != 0); 00477 00478 ((BorrowReturnMutableNodeRefList&)theSource).m_mutableNodeRefList = 0; 00479 } 00480 00481 ~BorrowReturnMutableNodeRefList() 00482 { 00483 if (m_mutableNodeRefList != 0) 00484 { 00485 m_xpathExecutionContext.returnMutableNodeRefList(m_mutableNodeRefList); 00486 } 00487 } 00488 00489 MutableNodeRefList& 00490 operator*() const 00491 { 00492 return *m_mutableNodeRefList; 00493 } 00494 00495 MutableNodeRefList* 00496 get() const 00497 { 00498 return m_mutableNodeRefList; 00499 } 00500 00501 MutableNodeRefList* 00502 operator->() const 00503 { 00504 return get(); 00505 } 00506 00507 BorrowReturnMutableNodeRefList 00508 clone() const 00509 { 00510 BorrowReturnMutableNodeRefList theResult(m_xpathExecutionContext); 00511 00512 *theResult = *m_mutableNodeRefList; 00513 00514 return theResult; 00515 } 00516 00517 private: 00518 00519 XPathExecutionContext& m_xpathExecutionContext; 00520 00521 MutableNodeRefList* m_mutableNodeRefList; 00522 }; 00523 00529 virtual MutableNodeRefList* 00530 createMutableNodeRefList() const = 0; 00531 00537 virtual bool 00538 getProcessNamespaces() const = 0; 00539 00551 virtual void 00552 getNodeSetByKey( 00553 XalanNode* doc, 00554 const XalanDOMString& name, 00555 const XalanDOMString& ref, 00556 const PrefixResolver& resolver, 00557 MutableNodeRefList& nodelist) = 0; 00558 00566 virtual const XObject* 00567 getVariable(const QName& name) const = 0; 00568 00574 virtual const PrefixResolver* 00575 getPrefixResolver() const = 0; 00576 00582 virtual void 00583 setPrefixResolver(const PrefixResolver* thePrefixResolver) = 0; 00584 00585 class PrefixResolverSetAndRestore 00586 { 00587 public: 00588 00589 PrefixResolverSetAndRestore( 00590 XPathExecutionContext& theExecutionContext, 00591 const PrefixResolver* theResolver) : 00592 m_executionContext(theExecutionContext), 00593 m_savedResolver(theExecutionContext.getPrefixResolver()) 00594 { 00595 m_executionContext.setPrefixResolver(theResolver); 00596 } 00597 00598 ~PrefixResolverSetAndRestore() 00599 { 00600 m_executionContext.setPrefixResolver(m_savedResolver); 00601 } 00602 00603 private: 00604 00605 XPathExecutionContext& m_executionContext; 00606 const PrefixResolver* const m_savedResolver; 00607 }; 00608 00615 virtual XalanDOMString 00616 getNamespaceForPrefix(const XalanDOMString& prefix) const = 0; 00617 00625 virtual XalanDOMString 00626 findURIFromDoc(const XalanDocument* owner) const = 0; 00627 00633 virtual XalanDocument* 00634 getDOMFactory() const = 0; 00635 00646 virtual XalanDOMString 00647 getUnparsedEntityURI( 00648 const XalanDOMString& theName, 00649 const XalanDocument& theDocument) const = 0; 00650 00661 virtual bool 00662 shouldStripSourceNode(const XalanNode& node) = 0; 00663 00671 virtual bool 00672 getThrowFoundIndex() const = 0; 00673 00681 virtual void 00682 setThrowFoundIndex(bool fThrow) = 0; 00683 00689 virtual void 00690 setCurrentPattern(const XalanDOMString& thePattern) = 0; 00691 00697 virtual XalanDOMString 00698 getCurrentPattern() const = 0; 00699 00700 virtual XalanDocument* 00701 getSourceDocument(const XalanDOMString& theURI) const = 0; 00702 00709 virtual void 00710 setSourceDocument( 00711 const XalanDOMString& theURI, 00712 XalanDocument* theDocument) = 0; 00713 00714 00722 virtual const XalanDecimalFormatSymbols* 00723 getDecimalFormatSymbols(const XalanDOMString& name) = 0; 00724 00725 // These interfaces are inherited from ExecutionContext... 00726 00727 virtual void 00728 error( 00729 const XalanDOMString& msg, 00730 const XalanNode* sourceNode = 0, 00731 const XalanNode* styleNode = 0) const = 0; 00732 00733 virtual void 00734 warn( 00735 const XalanDOMString& msg, 00736 const XalanNode* sourceNode = 0, 00737 const XalanNode* styleNode = 0) const = 0; 00738 00739 virtual void 00740 message( 00741 const XalanDOMString& msg, 00742 const XalanNode* sourceNode = 0, 00743 const XalanNode* styleNode = 0) const = 0; 00744 }; 00745 00746 00747 00748 #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.0 |
|