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 #if !defined(XPATH_HEADER_GUARD_1357924680) 00058 #define XPATH_HEADER_GUARD_1357924680 00059 00060 00061 00062 // Base header file. Must be first. 00063 #include <XPath/XPathDefinitions.hpp> 00064 00065 00066 00067 #include <XalanDOM/XalanDOMString.hpp> 00068 00069 00070 00071 // Base class header files... 00072 #include <XPath/XPathExecutionContext.hpp> 00073 00074 00075 00076 #include <XPath/XPathExpression.hpp> 00077 #include <XPath/Function.hpp> 00078 #include <XPath/XPathFunctionTable.hpp> 00079 00080 00081 00082 class PrefixResolver; 00083 class XLocator; 00084 class XObject; 00085 class XalanNode; 00086 00087 00088 00098 class XALAN_XPATH_EXPORT XPath 00099 { 00100 public: 00101 00102 static const XalanDOMString& PSEUDONAME_ANY; 00103 static const XalanDOMString& PSEUDONAME_ROOT; 00104 static const XalanDOMString& PSEUDONAME_TEXT; 00105 static const XalanDOMString& PSEUDONAME_COMMENT; 00106 static const XalanDOMString& PSEUDONAME_PI; 00107 static const XalanDOMString& PSEUDONAME_OTHER; 00108 00109 #if defined(XALAN_NO_NAMESPACES) 00110 typedef vector<XalanDOMString> TargetElementStringsVectorType; 00111 #else 00112 typedef std::vector<XalanDOMString> TargetElementStringsVectorType; 00113 #endif 00114 00115 00119 static void 00120 initialize(); 00121 00125 static void 00126 terminate(); 00127 00134 explicit 00135 XPath(bool createDefaultLocator = true); 00136 00137 virtual 00138 ~XPath(); 00139 00143 virtual void 00144 shrink(); 00145 00154 virtual const XObjectPtr 00155 execute( 00156 XalanNode* context, 00157 const PrefixResolver& prefixResolver, 00158 XPathExecutionContext& executionContext) const; 00159 00169 virtual const XObjectPtr 00170 execute( 00171 XalanNode* context, 00172 const PrefixResolver& prefixResolver, 00173 const NodeRefListBase& contextNodeList, 00174 XPathExecutionContext& executionContext) const; 00175 00184 virtual const XObjectPtr 00185 execute(XPathExecutionContext& executionContext) const; 00186 00195 virtual const XObjectPtr 00196 executeMore( 00197 XalanNode* context, 00198 int opPos, 00199 XPathExecutionContext& executionContext) const; 00200 00209 virtual const XObjectPtr 00210 locationPath( 00211 XalanNode* context, 00212 int opPos, 00213 XPathExecutionContext& executionContext) const; 00214 00220 XPathExpression& 00221 getExpression() 00222 { 00223 return m_expression; 00224 } 00225 00231 const XPathExpression& 00232 getExpression() const 00233 { 00234 return m_expression; 00235 } 00236 00237 #if defined(XALAN_INLINE_INITIALIZATION) 00238 00241 const double s_MatchScoreNone = -9999999999999.0; 00242 00247 const double s_MatchScoreQName = 0.0; 00248 00252 const double s_MatchScoreNSWild = -0.25; 00253 00257 const double s_MatchScoreNodeTest = -0.5; 00258 00263 const double s_MatchScoreOther = 0.5; 00264 #else 00265 00268 static const double s_MatchScoreNone; 00269 00274 static const double s_MatchScoreQName; 00275 00279 static const double s_MatchScoreNSWild; 00280 00284 static const double s_MatchScoreNodeTest; 00285 00290 static const double s_MatchScoreOther; 00291 #endif 00292 00300 virtual double 00301 getMatchScore( 00302 XalanNode* context, 00303 const PrefixResolver& resolver, 00304 XPathExecutionContext& executionContext) const; 00305 00318 virtual double 00319 nodeTest( 00320 XalanNode* context, 00321 int opPos, 00322 int argLen, 00323 int stepType, 00324 XPathExecutionContext& executionContext) const; 00325 00334 virtual const XObjectPtr 00335 predicate( 00336 XalanNode* context, 00337 int opPos, 00338 XPathExecutionContext& executionContext) const; 00339 00345 virtual void 00346 getTargetElementStrings(TargetElementStringsVectorType& targetStrings) const; 00347 00354 static void 00355 installFunction( 00356 const XalanDOMString& funcName, 00357 const Function& func); 00358 00365 static bool 00366 uninstallFunction(const XalanDOMString& funcName); 00367 00374 static bool 00375 isInstalledFunction(const XalanDOMString& theFunctionName) 00376 { 00377 return s_functions.isInstalledFunction(theFunctionName); 00378 } 00379 00380 typedef XPathFunctionTable FunctionTableType; 00381 00387 static const FunctionTableType& 00388 getFunctionTable() 00389 { 00390 return s_functions; 00391 } 00392 00393 #if defined(XALAN_NO_MEMBER_TEMPLATES) 00394 typedef XPathFunctionTable::InstalledFunctionNameVectorType 00395 InstalledFunctionNameVectorType; 00396 00402 static void 00403 getInstalledFunctionNames(InstalledFunctionNameVectorType& theVector) 00404 { 00405 s_functions.getInstalledFunctionNames(theVector); 00406 } 00407 #else 00408 00413 template<class OutputIteratorType> 00414 static void 00415 getInstalledFunctionNames(OutputIteratorType theIterator) 00416 { 00417 s_functions.getInstalledFunctionNames(theIterator); 00418 } 00419 #endif 00420 00421 static void 00422 destroyTable() 00423 { 00424 s_functions.DestroyTable(); 00425 } 00426 00427 bool 00428 getInStylesheet() const 00429 { 00430 return m_inStylesheet; 00431 } 00432 00433 void 00434 setInStylesheet(bool fValue) 00435 { 00436 m_inStylesheet = fValue; 00437 } 00438 00439 protected: 00440 00444 virtual XLocator* 00445 createXLocatorHandler() const; 00446 00453 virtual const XObjectPtr 00454 xpath( 00455 XalanNode* context, 00456 int opPos, 00457 XPathExecutionContext& executionContext) const; 00458 00465 virtual const XObjectPtr 00466 matchPattern( 00467 XalanNode* context, 00468 int opPos, 00469 XPathExecutionContext& executionContext) const; 00470 00479 MutableNodeRefList* 00480 step( 00481 XalanNode* context, 00482 int opPos, 00483 XPathExecutionContext& executionContext) const; 00484 00485 protected: 00486 00493 const XObjectPtr 00494 Or( 00495 XalanNode* context, 00496 int opPos, 00497 XPathExecutionContext& executionContext) const; 00498 00505 const XObjectPtr 00506 And( 00507 XalanNode* context, 00508 int opPos, 00509 XPathExecutionContext& executionContext) const; 00510 00517 const XObjectPtr 00518 notequals( 00519 XalanNode* context, 00520 int opPos, 00521 XPathExecutionContext& executionContext) const; 00522 00529 const XObjectPtr 00530 equals( 00531 XalanNode* context, 00532 int opPos, 00533 XPathExecutionContext& executionContext) const; 00534 00541 const XObjectPtr 00542 lte( 00543 XalanNode* context, 00544 int opPos, 00545 XPathExecutionContext& executionContext) const; 00546 00553 const XObjectPtr 00554 lt( 00555 XalanNode* context, 00556 int opPos, 00557 XPathExecutionContext& executionContext) const; 00558 00565 const XObjectPtr 00566 gte( 00567 XalanNode* context, 00568 int opPos, 00569 XPathExecutionContext& executionContext) const; 00570 00577 const XObjectPtr 00578 gt( 00579 XalanNode* context, 00580 int opPos, 00581 XPathExecutionContext& executionContext) const; 00582 00589 const XObjectPtr 00590 plus( 00591 XalanNode* context, 00592 int opPos, 00593 XPathExecutionContext& executionContext) const; 00594 00601 const XObjectPtr 00602 minus( 00603 XalanNode* context, 00604 int opPos, 00605 XPathExecutionContext& executionContext) const; 00606 00613 const XObjectPtr 00614 mult( 00615 XalanNode* context, 00616 int opPos, 00617 XPathExecutionContext& executionContext) const; 00618 00625 const XObjectPtr 00626 div( 00627 XalanNode* context, 00628 int opPos, 00629 XPathExecutionContext& executionContext) const; 00630 00637 const XObjectPtr 00638 mod( 00639 XalanNode* context, 00640 int opPos, 00641 XPathExecutionContext& executionContext) const; 00642 00650 const XObjectPtr 00651 quo( 00652 XalanNode* context, 00653 int opPos, 00654 XPathExecutionContext& executionContext) const; 00655 00662 const XObjectPtr 00663 neg( 00664 XalanNode* context, 00665 int opPos, 00666 XPathExecutionContext& executionContext) const; 00667 00674 const XObjectPtr 00675 string( 00676 XalanNode* context, 00677 int opPos, 00678 XPathExecutionContext& executionContext) const; 00679 00686 const XObjectPtr 00687 boolean( 00688 XalanNode* context, 00689 int opPos, 00690 XPathExecutionContext& executionContext) const; 00691 00698 const XObjectPtr 00699 number( 00700 XalanNode* context, 00701 int opPos, 00702 XPathExecutionContext& executionContext) const; 00703 00710 const XObjectPtr 00711 Union( 00712 XalanNode* context, 00713 int opPos, 00714 XPathExecutionContext& executionContext) const; 00715 00722 const XObjectPtr 00723 literal( 00724 XalanNode* context, 00725 int opPos, 00726 XPathExecutionContext& executionContext) const; 00727 00734 const XObjectPtr 00735 variable( 00736 XalanNode* context, 00737 int opPos, 00738 XPathExecutionContext& executionContext) const; 00739 00746 const XObjectPtr 00747 group( 00748 XalanNode* context, 00749 int opPos, 00750 XPathExecutionContext& executionContext) const; 00751 00758 const XObjectPtr 00759 numberlit( 00760 XalanNode* context, 00761 int opPos, 00762 XPathExecutionContext& executionContext) const; 00763 00770 const XObjectPtr 00771 arg( 00772 XalanNode* context, 00773 int opPos, 00774 XPathExecutionContext& executionContext) const; 00775 00783 const XObjectPtr 00784 locationPathPattern( 00785 XalanNode* context, 00786 int opPos, 00787 XPathExecutionContext& executionContext) const; 00788 00792 const XObjectPtr 00793 runExtFunction( 00794 XalanNode* context, 00795 int opPos, 00796 XPathExecutionContext& executionContext) const; 00797 00801 const XObjectPtr 00802 extfunction( 00803 XalanNode* context, 00804 int opPos, 00805 const XalanDOMString& theNamespace, 00806 const XalanDOMString& functionName, 00807 const Function::XObjectArgVectorType& argVec, 00808 XPathExecutionContext& executionContext) const; 00809 00813 const XObjectPtr 00814 runFunction( 00815 XalanNode* context, 00816 int opPos, 00817 XPathExecutionContext& executionContext) const; 00818 00822 const XObjectPtr 00823 function( 00824 XalanNode* context, 00825 int opPos, 00826 int funcID, 00827 const Function::XObjectArgVectorType& argVec, 00828 XPathExecutionContext& executionContext) const; 00829 00830 private: 00831 00832 // These are not implemented... 00833 XPath(const XPath&); 00834 00835 XPath& 00836 operator=(const XPath&); 00837 00838 bool 00839 operator==(const XPath&) const; 00840 00841 // Default vector allocation sizes. 00842 enum 00843 { 00844 eDefaultTargetStringsSize = 5 00845 }; 00846 00847 // Data members... 00848 00855 XLocator* m_defaultXLocator; 00856 00862 XPathExpression m_expression; 00863 00869 bool m_inStylesheet; 00870 00876 static FunctionTableType s_functions; 00877 }; 00878 00879 00880 00881 #endif // XPATH_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 |
|