00001 /* 00002 * The Apache Software License, Version 1.1 00003 * 00004 * 00005 * Copyright (c) 1999-2004 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 <xalanc/XPath/XPathDefinitions.hpp> 00064 00065 00066 00067 #include <xalanc/XalanDOM/XalanDOMString.hpp> 00068 00069 00070 00071 #include <xalanc/PlatformSupport/DoubleSupport.hpp> 00072 00073 00074 00075 // Base class header files... 00076 #include <xalanc/XPath/XPathExecutionContext.hpp> 00077 00078 00079 00080 #include <xalanc/XPath/MutableNodeRefList.hpp> 00081 #include <xalanc/XPath/XPathExpression.hpp> 00082 #include <xalanc/XPath/Function.hpp> 00083 #include <xalanc/XPath/XPathFunctionTable.hpp> 00084 00085 00086 00087 XALAN_DECLARE_XERCES_CLASS(Locator) 00088 00089 00090 00091 XALAN_CPP_NAMESPACE_BEGIN 00092 00093 00094 00095 class PrefixResolver; 00096 class XObject; 00097 class XalanNode; 00098 00099 00100 00101 class XALAN_XPATH_EXPORT XPath 00102 { 00103 public: 00104 00105 typedef XERCES_CPP_NAMESPACE_QUALIFIER Locator LocatorType; 00106 00107 static const XalanDOMChar PSEUDONAME_ANY[]; 00108 static const XalanDOMChar PSEUDONAME_ROOT[]; 00109 static const XalanDOMChar PSEUDONAME_TEXT[]; 00110 static const XalanDOMChar PSEUDONAME_COMMENT[]; 00111 static const XalanDOMChar PSEUDONAME_PI[]; 00112 static const XalanDOMChar PSEUDONAME_OTHER[]; 00113 static const XalanDOMChar PSEUDONAME_NODE[]; 00114 00115 enum eMatchScore 00116 { 00117 eMatchScoreNone, 00118 eMatchScoreNodeTest, 00119 eMatchScoreNSWild, 00120 eMatchScoreQName, 00121 eMatchScoreOther 00122 }; 00123 00124 class TargetData 00125 { 00126 public: 00127 00128 enum eTargetType { eAttribute, eElement, eAny, eOther }; 00129 00130 TargetData() : 00131 m_string(0), 00132 m_priority(eMatchScoreNone), 00133 m_targetType(eOther) 00134 { 00135 } 00136 00137 TargetData( 00138 const XalanDOMChar* theString, 00139 eMatchScore thePriority, 00140 eTargetType theTargetType) : 00141 m_string(theString), 00142 m_priority(thePriority), 00143 m_targetType(theTargetType) 00144 { 00145 } 00146 00147 const XalanDOMChar* 00148 getString() const 00149 { 00150 return m_string; 00151 } 00152 00153 eMatchScore 00154 getDefaultPriority() const 00155 { 00156 return m_priority; 00157 } 00158 00159 eTargetType 00160 getTargetType() const 00161 { 00162 return m_targetType; 00163 } 00164 00165 private: 00166 00167 const XalanDOMChar* m_string; 00168 00169 eMatchScore m_priority; 00170 00171 eTargetType m_targetType; 00172 }; 00173 00174 #if defined(XALAN_NO_STD_NAMESPACE) 00175 typedef vector<TargetData> TargetDataVectorType; 00176 #else 00177 typedef std::vector<TargetData> TargetDataVectorType; 00178 #endif 00179 00180 00184 static void 00185 initialize(); 00186 00190 static void 00191 terminate(); 00192 00198 explicit 00199 XPath(const LocatorType* theLocator = 0); 00200 00201 ~XPath(); 00202 00206 void 00207 shrink() 00208 { 00209 m_expression.shrink(); 00210 } 00211 00220 const XObjectPtr 00221 execute( 00222 XalanNode* context, 00223 const PrefixResolver& prefixResolver, 00224 XPathExecutionContext& executionContext) const; 00225 00234 void 00235 execute( 00236 XalanNode* context, 00237 const PrefixResolver& prefixResolver, 00238 XPathExecutionContext& executionContext, 00239 bool& result) const; 00240 00249 void 00250 execute( 00251 XalanNode* context, 00252 const PrefixResolver& prefixResolver, 00253 XPathExecutionContext& executionContext, 00254 double& result) const; 00255 00265 void 00266 execute( 00267 XalanNode* context, 00268 const PrefixResolver& prefixResolver, 00269 XPathExecutionContext& executionContext, 00270 XalanDOMString& result) const; 00271 00272 typedef void (FormatterListener::*MemberFunctionPtr)(const XMLCh* const, const unsigned int); 00273 00283 void 00284 execute( 00285 XalanNode* context, 00286 const PrefixResolver& prefixResolver, 00287 XPathExecutionContext& executionContext, 00288 FormatterListener& formatterListener, 00289 MemberFunctionPtr function) const; 00290 00310 const XObjectPtr 00311 execute( 00312 XalanNode* context, 00313 const PrefixResolver& prefixResolver, 00314 XPathExecutionContext& executionContext, 00315 MutableNodeRefList& result) const; 00316 00326 const XObjectPtr 00327 execute( 00328 XalanNode* context, 00329 const PrefixResolver& prefixResolver, 00330 const NodeRefListBase& contextNodeList, 00331 XPathExecutionContext& executionContext) const 00332 { 00333 // Push and pop the context node list... 00334 XPathExecutionContext::ContextNodeListPushAndPop thePushAndPop( 00335 executionContext, 00336 contextNodeList); 00337 00338 return execute(context, prefixResolver, executionContext); 00339 } 00340 00350 void 00351 execute( 00352 XalanNode* context, 00353 const PrefixResolver& prefixResolver, 00354 const NodeRefListBase& contextNodeList, 00355 XPathExecutionContext& executionContext, 00356 bool& result) const 00357 { 00358 // Push and pop the context node list... 00359 XPathExecutionContext::ContextNodeListPushAndPop thePushAndPop( 00360 executionContext, 00361 contextNodeList); 00362 00363 execute(context, prefixResolver, executionContext, result); 00364 } 00365 00375 void 00376 execute( 00377 XalanNode* context, 00378 const PrefixResolver& prefixResolver, 00379 const NodeRefListBase& contextNodeList, 00380 XPathExecutionContext& executionContext, 00381 double& result) const 00382 { 00383 // Push and pop the context node list... 00384 XPathExecutionContext::ContextNodeListPushAndPop thePushAndPop( 00385 executionContext, 00386 contextNodeList); 00387 00388 execute(context, prefixResolver, executionContext, result); 00389 } 00390 00401 void 00402 execute( 00403 XalanNode* context, 00404 const PrefixResolver& prefixResolver, 00405 const NodeRefListBase& contextNodeList, 00406 XPathExecutionContext& executionContext, 00407 XalanDOMString& result) const 00408 { 00409 // Push and pop the context node list... 00410 XPathExecutionContext::ContextNodeListPushAndPop thePushAndPop( 00411 executionContext, 00412 contextNodeList); 00413 00414 execute(context, prefixResolver, executionContext, result); 00415 } 00416 00427 void 00428 execute( 00429 XalanNode* context, 00430 const PrefixResolver& prefixResolver, 00431 const NodeRefListBase& contextNodeList, 00432 XPathExecutionContext& executionContext, 00433 FormatterListener& formatterListener, 00434 MemberFunctionPtr function) const 00435 { 00436 // Push and pop the context node list... 00437 XPathExecutionContext::ContextNodeListPushAndPop thePushAndPop( 00438 executionContext, 00439 contextNodeList); 00440 00441 execute(context, prefixResolver, executionContext, formatterListener, function); 00442 } 00443 00464 const XObjectPtr 00465 execute( 00466 XalanNode* context, 00467 const PrefixResolver& prefixResolver, 00468 const NodeRefListBase& contextNodeList, 00469 XPathExecutionContext& executionContext, 00470 MutableNodeRefList& result) const 00471 { 00472 // Push and pop the context node list... 00473 XPathExecutionContext::ContextNodeListPushAndPop thePushAndPop( 00474 executionContext, 00475 contextNodeList); 00476 00477 return execute(context, prefixResolver, executionContext, result); 00478 } 00479 00489 const XObjectPtr 00490 execute(XPathExecutionContext& executionContext) const 00491 { 00492 assert(executionContext.getCurrentNode() != 0); 00493 assert(executionContext.getPrefixResolver() != 0); 00494 00495 return executeMore(executionContext.getCurrentNode(), 0, executionContext); 00496 } 00497 00507 void 00508 execute( 00509 XPathExecutionContext& executionContext, 00510 bool& result) const 00511 { 00512 assert(executionContext.getCurrentNode() != 0); 00513 assert(executionContext.getPrefixResolver() != 0); 00514 00515 executeMore(executionContext.getCurrentNode(), 0, executionContext, result); 00516 } 00517 00527 void 00528 execute( 00529 XPathExecutionContext& executionContext, 00530 double& result) const 00531 { 00532 assert(executionContext.getCurrentNode() != 0); 00533 assert(executionContext.getPrefixResolver() != 0); 00534 00535 executeMore(executionContext.getCurrentNode(), 0, executionContext, result); 00536 } 00537 00548 void 00549 execute( 00550 XPathExecutionContext& executionContext, 00551 XalanDOMString& result) const 00552 { 00553 assert(executionContext.getCurrentNode() != 0); 00554 assert(executionContext.getPrefixResolver() != 0); 00555 00556 executeMore(executionContext.getCurrentNode(), 0, executionContext, result); 00557 } 00558 00569 void 00570 execute( 00571 XPathExecutionContext& executionContext, 00572 FormatterListener& formatterListener, 00573 MemberFunctionPtr function) const 00574 { 00575 assert(executionContext.getCurrentNode() != 0); 00576 assert(executionContext.getPrefixResolver() != 0); 00577 00578 executeMore(executionContext.getCurrentNode(), 0, executionContext, formatterListener, function); 00579 } 00580 00601 const XObjectPtr 00602 execute( 00603 XPathExecutionContext& executionContext, 00604 MutableNodeRefList& result) const 00605 { 00606 assert(executionContext.getCurrentNode() != 0); 00607 assert(executionContext.getPrefixResolver() != 0); 00608 00609 return executeMore(executionContext.getCurrentNode(), 0, executionContext, result); 00610 } 00611 00622 const XObjectPtr 00623 execute( 00624 const PrefixResolver& prefixResolver, 00625 XPathExecutionContext& executionContext) const 00626 { 00627 assert(executionContext.getCurrentNode() != 0); 00628 00629 // Push and pop the PrefixResolver... 00630 XPathExecutionContext::PrefixResolverSetAndRestore theResolverSetAndRestore( 00631 executionContext, 00632 &prefixResolver); 00633 00634 return executeMore(executionContext.getCurrentNode(), 0, executionContext); 00635 } 00636 00647 void 00648 execute( 00649 const PrefixResolver& prefixResolver, 00650 XPathExecutionContext& executionContext, 00651 bool& result) const 00652 { 00653 assert(executionContext.getCurrentNode() != 0); 00654 00655 // Push and pop the PrefixResolver... 00656 XPathExecutionContext::PrefixResolverSetAndRestore theResolverSetAndRestore( 00657 executionContext, 00658 &prefixResolver); 00659 00660 executeMore(executionContext.getCurrentNode(), 0, executionContext, result); 00661 } 00662 00673 void 00674 execute( 00675 const PrefixResolver& prefixResolver, 00676 XPathExecutionContext& executionContext, 00677 double& result) const 00678 { 00679 assert(executionContext.getCurrentNode() != 0); 00680 00681 // Push and pop the PrefixResolver... 00682 XPathExecutionContext::PrefixResolverSetAndRestore theResolverSetAndRestore( 00683 executionContext, 00684 &prefixResolver); 00685 00686 executeMore(executionContext.getCurrentNode(), 0, executionContext, result); 00687 } 00688 00700 void 00701 execute( 00702 const PrefixResolver& prefixResolver, 00703 XPathExecutionContext& executionContext, 00704 XalanDOMString& result) const 00705 { 00706 assert(executionContext.getCurrentNode() != 0); 00707 00708 // Push and pop the PrefixResolver... 00709 XPathExecutionContext::PrefixResolverSetAndRestore theResolverSetAndRestore( 00710 executionContext, 00711 &prefixResolver); 00712 00713 executeMore(executionContext.getCurrentNode(), 0, executionContext, result); 00714 } 00715 00724 void 00725 execute( 00726 const PrefixResolver& prefixResolver, 00727 XPathExecutionContext& executionContext, 00728 FormatterListener& formatterListener, 00729 MemberFunctionPtr function) const 00730 { 00731 assert(executionContext.getCurrentNode() != 0); 00732 00733 // Push and pop the PrefixResolver... 00734 XPathExecutionContext::PrefixResolverSetAndRestore theResolverSetAndRestore( 00735 executionContext, 00736 &prefixResolver); 00737 00738 executeMore(executionContext.getCurrentNode(), 0, executionContext, formatterListener, function); 00739 } 00740 00762 XObjectPtr 00763 execute( 00764 const PrefixResolver& prefixResolver, 00765 XPathExecutionContext& executionContext, 00766 MutableNodeRefList& result) const 00767 { 00768 assert(executionContext.getCurrentNode() != 0); 00769 00770 // Push and pop the PrefixResolver... 00771 XPathExecutionContext::PrefixResolverSetAndRestore theResolverSetAndRestore( 00772 executionContext, 00773 &prefixResolver); 00774 00775 return executeMore(executionContext.getCurrentNode(), 0, executionContext, result); 00776 } 00777 00783 XPathExpression& 00784 getExpression() 00785 { 00786 return m_expression; 00787 } 00788 00794 const XPathExpression& 00795 getExpression() const 00796 { 00797 return m_expression; 00798 } 00799 00800 static double 00801 getMatchScoreValue(eMatchScore score) 00802 { 00803 switch(score) 00804 { 00805 case eMatchScoreNone: 00806 return DoubleSupport::getNegativeInfinity(); 00807 break; 00808 00809 case eMatchScoreNodeTest: 00810 return -0.5; 00811 break; 00812 00813 case eMatchScoreNSWild: 00814 return -0.25; 00815 break; 00816 00817 case eMatchScoreOther: 00818 return 0.5; 00819 break; 00820 00821 case eMatchScoreQName: 00822 return 0.0; 00823 break; 00824 }; 00825 00826 assert(false); 00827 return 0.0; 00828 } 00829 00837 eMatchScore 00838 getMatchScore( 00839 XalanNode* node, 00840 XPathExecutionContext& executionContext) const; 00841 00850 eMatchScore 00851 getMatchScore( 00852 XalanNode* node, 00853 const PrefixResolver& resolver, 00854 XPathExecutionContext& executionContext) const; 00855 00864 const XObjectPtr 00865 predicate( 00866 XalanNode* context, 00867 int opPos, 00868 XPathExecutionContext& executionContext) const 00869 { 00870 return executeMore(context, opPos + 2, executionContext); 00871 } 00872 00878 void 00879 getTargetData(TargetDataVectorType& targetData) const; 00880 00887 static void 00888 installFunction( 00889 const XalanDOMString& funcName, 00890 const Function& func) 00891 { 00892 s_functions.InstallFunction(funcName, 00893 func); 00894 } 00895 00902 static void 00903 installFunction( 00904 const XalanDOMChar* funcName, 00905 const Function& func) 00906 { 00907 s_functions.InstallFunction(funcName, 00908 func); 00909 } 00910 00917 static bool 00918 uninstallFunction(const XalanDOMString& funcName) 00919 { 00920 return s_functions.UninstallFunction(funcName); 00921 } 00922 00929 static bool 00930 uninstallFunction(const XalanDOMChar* funcName) 00931 { 00932 return s_functions.UninstallFunction(funcName); 00933 } 00934 00941 static bool 00942 isInstalledFunction(const XalanDOMString& theFunctionName) 00943 { 00944 return s_functions.isInstalledFunction(theFunctionName); 00945 } 00946 00947 typedef XPathFunctionTable FunctionTableType; 00948 00954 static const FunctionTableType& 00955 getFunctionTable() 00956 { 00957 return s_functions; 00958 } 00959 00960 #if defined(XALAN_NO_MEMBER_TEMPLATES) 00961 typedef XPathFunctionTable::InstalledFunctionNameVectorType 00962 InstalledFunctionNameVectorType; 00963 00969 static void 00970 getInstalledFunctionNames(InstalledFunctionNameVectorType& theVector) 00971 { 00972 s_functions.getInstalledFunctionNames(theVector); 00973 } 00974 #else 00980 template<class OutputIteratorType> 00981 static void 00982 getInstalledFunctionNames(OutputIteratorType theIterator) 00983 { 00984 s_functions.getInstalledFunctionNames(theIterator); 00985 } 00986 #endif 00987 00988 static void 00989 destroyTable() 00990 { 00991 s_functions.DestroyTable(); 00992 } 00993 00994 bool 00995 getInStylesheet() const 00996 { 00997 return m_inStylesheet; 00998 } 00999 01000 void 01001 setInStylesheet(bool fValue) 01002 { 01003 m_inStylesheet = fValue; 01004 } 01005 01006 const LocatorType* 01007 getLocator() const 01008 { 01009 return m_locator; 01010 } 01011 01012 void 01013 setLocator(const LocatorType* theLocator) 01014 { 01015 m_locator = theLocator; 01016 } 01017 01018 protected: 01019 01028 const XObjectPtr 01029 locationPath( 01030 XalanNode* context, 01031 int opPos, 01032 XPathExecutionContext& executionContext) const; 01033 01042 void 01043 locationPath( 01044 XalanNode* context, 01045 int opPos, 01046 XPathExecutionContext& executionContext, 01047 bool& theResult) const; 01048 01057 void 01058 locationPath( 01059 XalanNode* context, 01060 int opPos, 01061 XPathExecutionContext& executionContext, 01062 double& theResult) const; 01063 01072 void 01073 locationPath( 01074 XalanNode* context, 01075 int opPos, 01076 XPathExecutionContext& executionContext, 01077 XalanDOMString& theResult) const; 01078 01088 void 01089 locationPath( 01090 XalanNode* context, 01091 int opPos, 01092 XPathExecutionContext& executionContext, 01093 FormatterListener& formatterListener, 01094 MemberFunctionPtr function) const; 01095 01104 void 01105 locationPath( 01106 XalanNode* context, 01107 int opPos, 01108 XPathExecutionContext& executionContext, 01109 MutableNodeRefList& theResult) const 01110 { 01111 step(executionContext, context, opPos + 2, theResult); 01112 } 01113 01122 const XObjectPtr 01123 executeMore( 01124 XalanNode* context, 01125 int opPos, 01126 XPathExecutionContext& executionContext) const; 01127 01136 void 01137 executeMore( 01138 XalanNode* context, 01139 int opPos, 01140 XPathExecutionContext& executionContext, 01141 bool& theResult) const; 01142 01151 void 01152 executeMore( 01153 XalanNode* context, 01154 int opPos, 01155 XPathExecutionContext& executionContext, 01156 double& theResult) const; 01157 01167 void 01168 executeMore( 01169 XalanNode* context, 01170 int opPos, 01171 XPathExecutionContext& executionContext, 01172 XalanDOMString& theResult) const; 01173 01183 void 01184 executeMore( 01185 XalanNode* context, 01186 int opPos, 01187 XPathExecutionContext& executionContext, 01188 FormatterListener& formatterListener, 01189 MemberFunctionPtr function) const; 01190 01200 const XObjectPtr 01201 executeMore( 01202 XalanNode* context, 01203 int opPos, 01204 XPathExecutionContext& executionContext, 01205 MutableNodeRefList& theResult) const; 01206 01213 void 01214 doGetMatchScore( 01215 XalanNode* context, 01216 XPathExecutionContext& executionContext, 01217 eMatchScore& score) const; 01218 01226 bool 01227 Or( 01228 XalanNode* context, 01229 int opPos, 01230 XPathExecutionContext& executionContext) const; 01231 01239 bool 01240 And( 01241 XalanNode* context, 01242 int opPos, 01243 XPathExecutionContext& executionContext) const; 01244 01252 bool 01253 notequals( 01254 XalanNode* context, 01255 int opPos, 01256 XPathExecutionContext& executionContext) const; 01257 01265 bool 01266 equals( 01267 XalanNode* context, 01268 int opPos, 01269 XPathExecutionContext& executionContext) const; 01270 01278 bool 01279 lte( 01280 XalanNode* context, 01281 int opPos, 01282 XPathExecutionContext& executionContext) const; 01283 01291 bool 01292 lt( 01293 XalanNode* context, 01294 int opPos, 01295 XPathExecutionContext& executionContext) const; 01296 01304 bool 01305 gte( 01306 XalanNode* context, 01307 int opPos, 01308 XPathExecutionContext& executionContext) const; 01309 01317 bool 01318 gt( 01319 XalanNode* context, 01320 int opPos, 01321 XPathExecutionContext& executionContext) const; 01322 01330 double 01331 plus( 01332 XalanNode* context, 01333 int opPos, 01334 XPathExecutionContext& executionContext) const; 01335 01344 void 01345 plus( 01346 XalanNode* context, 01347 int opPos, 01348 XPathExecutionContext& executionContext, 01349 FormatterListener& formatterListener, 01350 MemberFunctionPtr function) const; 01351 01359 double 01360 minus( 01361 XalanNode* context, 01362 int opPos, 01363 XPathExecutionContext& executionContext) const; 01364 01373 void 01374 minus( 01375 XalanNode* context, 01376 int opPos, 01377 XPathExecutionContext& executionContext, 01378 FormatterListener& formatterListener, 01379 MemberFunctionPtr function) const; 01380 01388 double 01389 mult( 01390 XalanNode* context, 01391 int opPos, 01392 XPathExecutionContext& executionContext) const; 01393 01402 void 01403 mult( 01404 XalanNode* context, 01405 int opPos, 01406 XPathExecutionContext& executionContext, 01407 FormatterListener& formatterListener, 01408 MemberFunctionPtr function) const; 01409 01417 double 01418 div( 01419 XalanNode* context, 01420 int opPos, 01421 XPathExecutionContext& executionContext) const; 01422 01431 void 01432 div( 01433 XalanNode* context, 01434 int opPos, 01435 XPathExecutionContext& executionContext, 01436 FormatterListener& formatterListener, 01437 MemberFunctionPtr function) const; 01438 01446 double 01447 mod( 01448 XalanNode* context, 01449 int opPos, 01450 XPathExecutionContext& executionContext) const; 01451 01460 void 01461 mod( 01462 XalanNode* context, 01463 int opPos, 01464 XPathExecutionContext& executionContext, 01465 FormatterListener& formatterListener, 01466 MemberFunctionPtr function) const; 01467 01475 double 01476 neg( 01477 XalanNode* context, 01478 int opPos, 01479 XPathExecutionContext& executionContext) const; 01480 01489 void 01490 neg( 01491 XalanNode* context, 01492 int opPos, 01493 XPathExecutionContext& executionContext, 01494 FormatterListener& formatterListener, 01495 MemberFunctionPtr function) const; 01496 01504 const XObjectPtr 01505 Union( 01506 XalanNode* context, 01507 int opPos, 01508 XPathExecutionContext& executionContext) const; 01509 01518 void 01519 Union( 01520 XalanNode* context, 01521 int opPos, 01522 XPathExecutionContext& executionContext, 01523 bool& result) const; 01524 01533 void 01534 Union( 01535 XalanNode* context, 01536 int opPos, 01537 XPathExecutionContext& executionContext, 01538 double& result) const; 01539 01548 void 01549 Union( 01550 XalanNode* context, 01551 int opPos, 01552 XPathExecutionContext& executionContext, 01553 XalanDOMString& result) const; 01554 01564 void 01565 Union( 01566 XalanNode* context, 01567 int opPos, 01568 XPathExecutionContext& executionContext, 01569 FormatterListener& formatterListener, 01570 MemberFunctionPtr function) const; 01571 01579 void 01580 Union( 01581 XalanNode* context, 01582 int opPos, 01583 XPathExecutionContext& executionContext, 01584 MutableNodeRefList& result) const; 01585 01592 const XObjectPtr 01593 literal( 01594 int opPos, 01595 XPathExecutionContext& executionContext) const; 01596 01603 void 01604 literal( 01605 int opPos, 01606 bool& theResult) const; 01607 01614 void 01615 literal( 01616 int opPos, 01617 double& theResult) const; 01618 01626 void 01627 literal( 01628 int opPos, 01629 XalanDOMString& theResult) const; 01630 01637 void 01638 literal( 01639 int opPos, 01640 FormatterListener& formatterListener, 01641 MemberFunctionPtr function) const; 01642 01649 const XObjectPtr 01650 variable( 01651 int opPos, 01652 XPathExecutionContext& executionContext) const; 01653 01661 const XObjectPtr 01662 group( 01663 XalanNode* context, 01664 int opPos, 01665 XPathExecutionContext& executionContext) const 01666 { 01667 return executeMore(context, opPos + 2, executionContext); 01668 } 01669 01677 void 01678 group( 01679 XalanNode* context, 01680 int opPos, 01681 XPathExecutionContext& executionContext, 01682 bool& theResult) const 01683 { 01684 executeMore(context, opPos + 2, executionContext, theResult); 01685 } 01686 01694 void 01695 group( 01696 XalanNode* context, 01697 int opPos, 01698 XPathExecutionContext& executionContext, 01699 double& theResult) const 01700 { 01701 executeMore(context, opPos + 2, executionContext, theResult); 01702 } 01703 01711 void 01712 group( 01713 XalanNode* context, 01714 int opPos, 01715 XPathExecutionContext& executionContext, 01716 XalanDOMString& theResult) const 01717 { 01718 executeMore(context, opPos + 2, executionContext, theResult); 01719 } 01720 01730 void 01731 group( 01732 XalanNode* context, 01733 int opPos, 01734 XPathExecutionContext& executionContext, 01735 FormatterListener& formatterListener, 01736 MemberFunctionPtr function) const 01737 { 01738 executeMore(context, opPos + 2, executionContext, formatterListener, function); 01739 } 01740 01748 void 01749 group( 01750 XalanNode* context, 01751 int opPos, 01752 XPathExecutionContext& executionContext, 01753 MutableNodeRefList& theResult) const 01754 { 01755 executeMore(context, opPos + 2, executionContext, theResult); 01756 } 01757 01763 double 01764 numberlit(int opPos) const; 01765 01771 const XObjectPtr 01772 numberlit( 01773 int opPos, 01774 XPathExecutionContext& executionContext) const; 01775 01782 void 01783 numberlit( 01784 int opPos, 01785 bool& theResult) const; 01786 01794 void 01795 numberlit( 01796 int opPos, 01797 XalanDOMString& theResult) const; 01798 01806 void 01807 numberlit( 01808 int opPos, 01809 FormatterListener& formatterListener, 01810 MemberFunctionPtr function) const; 01811 01819 const XObjectPtr 01820 runExtFunction( 01821 XalanNode* context, 01822 int opPos, 01823 XPathExecutionContext& executionContext) const; 01824 01835 const XObjectPtr 01836 extfunction( 01837 XalanNode* context, 01838 int /* opPos */, 01839 const XalanDOMString& theNamespace, 01840 const XalanDOMString& functionName, 01841 const Function::XObjectArgVectorType& argVec, 01842 XPathExecutionContext& executionContext) const 01843 { 01844 return executionContext.extFunction(theNamespace, 01845 functionName, 01846 context, 01847 argVec, 01848 m_locator); 01849 } 01850 01858 const XObjectPtr 01859 runFunction( 01860 XalanNode* context, 01861 int opPos, 01862 XPathExecutionContext& executionContext) const; 01863 01872 const XObjectPtr 01873 function( 01874 XalanNode* context, 01875 int funcID, 01876 const Function::XObjectArgVectorType& argVec, 01877 XPathExecutionContext& executionContext) const 01878 { 01879 return s_functions[funcID].execute(executionContext, context, argVec, m_locator); 01880 } 01881 01889 double 01890 functionPosition( 01891 XalanNode* context, 01892 XPathExecutionContext& executionContext) const 01893 { 01894 assert(context != 0); 01895 01896 return executionContext.getContextNodeListPosition(*context); 01897 } 01898 01905 double 01906 functionLast(XPathExecutionContext& executionContext) const 01907 { 01908 return executionContext.getContextNodeListLength(); 01909 } 01910 01919 double 01920 functionCount( 01921 XalanNode* context, 01922 int opPos, 01923 XPathExecutionContext& executionContext) const; 01924 01933 bool 01934 functionNot( 01935 XalanNode* context, 01936 int opPos, 01937 XPathExecutionContext& executionContext) const 01938 { 01939 assert(context != 0); 01940 01941 return !functionBoolean(context, opPos, executionContext); 01942 } 01943 01952 bool 01953 functionBoolean( 01954 XalanNode* context, 01955 int opPos, 01956 XPathExecutionContext& executionContext) const 01957 { 01958 assert(context != 0); 01959 01960 bool result; 01961 01962 executeMore(context, opPos + 2, executionContext, result); 01963 01964 return result; 01965 } 01966 01973 const XalanDOMString& 01974 functionName(XalanNode* context) const 01975 { 01976 assert(context != 0); 01977 01978 return DOMServices::getNameOfNode(*context); 01979 } 01980 01989 const XalanDOMString& 01990 functionName( 01991 XalanNode* context, 01992 int opPos, 01993 XPathExecutionContext& executionContext) const; 01994 02001 const XalanDOMString& 02002 functionLocalName(XalanNode* context) const; 02003 02012 const XalanDOMString& 02013 functionLocalName( 02014 XalanNode* context, 02015 int opPos, 02016 XPathExecutionContext& executionContext) const; 02017 02025 double 02026 functionNumber( 02027 XalanNode* context, 02028 XPathExecutionContext& executionContext) const 02029 { 02030 assert(context != 0); 02031 02032 return XObject::number(executionContext, *context); 02033 } 02034 02043 double 02044 functionNumber( 02045 XalanNode* context, 02046 int opPos, 02047 XPathExecutionContext& executionContext) const 02048 { 02049 double result; 02050 02051 executeMore(context, opPos + 2, executionContext, result); 02052 02053 return result; 02054 } 02055 02064 double 02065 functionFloor( 02066 XalanNode* context, 02067 int opPos, 02068 XPathExecutionContext& executionContext) const 02069 { 02070 return DoubleSupport::floor(functionNumber(context, opPos, executionContext)); 02071 } 02072 02081 double 02082 functionCeiling( 02083 XalanNode* context, 02084 int opPos, 02085 XPathExecutionContext& executionContext) const 02086 { 02087 return DoubleSupport::ceiling(functionNumber(context, opPos, executionContext)); 02088 } 02089 02098 double 02099 functionRound( 02100 XalanNode* context, 02101 int opPos, 02102 XPathExecutionContext& executionContext) const 02103 { 02104 return DoubleSupport::round(functionNumber(context, opPos, executionContext)); 02105 } 02106 02113 double 02114 functionStringLength(XalanNode* context) const; 02115 02124 double 02125 functionStringLength( 02126 XalanNode* context, 02127 int opPos, 02128 XPathExecutionContext& executionContext) const; 02129 02138 double 02139 functionSum( 02140 XalanNode* context, 02141 int opPos, 02142 XPathExecutionContext& executionContext) const; 02143 02151 double 02152 getNumericOperand( 02153 XalanNode* context, 02154 int opPos, 02155 XPathExecutionContext& executionContext) const; 02156 02157 private: 02158 02159 // These are not implemented... 02160 XPath(const XPath&); 02161 02162 XPath& 02163 operator=(const XPath&); 02164 02165 bool 02166 operator==(const XPath&) const; 02167 02168 // Default vector allocation sizes. 02169 enum 02170 { 02171 eDefaultTargetDataSize = 5 02172 }; 02173 02174 eMatchScore 02175 locationPathPattern( 02176 XPathExecutionContext& executionContext, 02177 XalanNode& context, 02178 int opPos) const; 02179 02180 class NodeTester 02181 { 02182 public: 02183 02184 NodeTester( 02185 const XPath& xpath, 02186 XPathExecutionContext& executionContext, 02187 int opPos, 02188 int argLen, 02189 int stepType); 02190 02191 eMatchScore 02192 operator()( 02193 const XalanNode& context, 02194 XalanNode::NodeType nodeType) const 02195 { 02196 assert(context.getNodeType() == nodeType); 02197 02198 return (this->*m_testFunction)(context, nodeType); 02199 } 02200 02201 private: 02202 02203 typedef eMatchScore (NodeTester::*TestFunctionPtr)(const XalanNode&, XalanNode::NodeType) const; 02204 02205 02206 eMatchScore 02207 testComment( 02208 const XalanNode& context, 02209 XalanNode::NodeType nodeType) const; 02210 02211 eMatchScore 02212 testText( 02213 const XalanNode& context, 02214 XalanNode::NodeType nodeType) const; 02215 02216 eMatchScore 02217 testPI( 02218 const XalanNode& context, 02219 XalanNode::NodeType nodeType) const; 02220 02221 eMatchScore 02222 testPIName( 02223 const XalanNode& context, 02224 XalanNode::NodeType nodeType) const; 02225 02226 eMatchScore 02227 testNode( 02228 const XalanNode& context, 02229 XalanNode::NodeType nodeType) const; 02230 02231 eMatchScore 02232 testRoot( 02233 const XalanNode& context, 02234 XalanNode::NodeType nodeType) const; 02235 02236 eMatchScore 02237 testAttributeNCName( 02238 const XalanNode& context, 02239 XalanNode::NodeType nodeType) const; 02240 02241 eMatchScore 02242 testAttributeQName( 02243 const XalanNode& context, 02244 XalanNode::NodeType nodeType) const; 02245 02246 eMatchScore 02247 testAttributeNamespaceOnly( 02248 const XalanNode& context, 02249 XalanNode::NodeType nodeType) const; 02250 02251 eMatchScore 02252 testAttributeTotallyWild( 02253 const XalanNode& context, 02254 XalanNode::NodeType nodeType) const; 02255 02256 eMatchScore 02257 testElementNCName( 02258 const XalanNode& context, 02259 XalanNode::NodeType nodeType) const; 02260 02261 eMatchScore 02262 testElementQName( 02263 const XalanNode& context, 02264 XalanNode::NodeType nodeType) const; 02265 02266 eMatchScore 02267 testElementNamespaceOnly( 02268 const XalanNode& context, 02269 XalanNode::NodeType nodeType) const; 02270 02271 eMatchScore 02272 testElementTotallyWild( 02273 const XalanNode& context, 02274 XalanNode::NodeType nodeType) const; 02275 02276 eMatchScore 02277 testNamespaceNCName( 02278 const XalanNode& context, 02279 XalanNode::NodeType nodeType) const; 02280 02281 eMatchScore 02282 testNamespaceTotallyWild( 02283 const XalanNode& context, 02284 XalanNode::NodeType nodeType) const; 02285 02286 eMatchScore 02287 testDefault( 02288 const XalanNode& context, 02289 XalanNode::NodeType nodeType) const; 02290 02291 bool 02292 matchLocalName(const XalanNode& context) const; 02293 02294 bool 02295 matchNamespaceURI(const XalanNode& context) const; 02296 02297 bool 02298 matchLocalNameAndNamespaceURI(const XalanNode& context) const; 02299 02300 bool 02301 matchNamespace(const XalanNode& context) const; 02302 02303 bool 02304 shouldStripSourceNode(const XalanNode& context) const; 02305 02306 // Data members... 02307 XPathExecutionContext& m_executionContext; 02308 02309 const XalanDOMString* m_targetNamespace; 02310 02311 const XalanDOMString* m_targetLocalName; 02312 02313 TestFunctionPtr m_testFunction; 02314 }; 02315 02316 protected: 02317 02318 void 02319 step( 02320 XPathExecutionContext& executionContext, 02321 XalanNode* context, 02322 int opPos, 02323 MutableNodeRefList& queryResults) const; 02324 02335 XalanNode* 02336 stepPattern( 02337 XPathExecutionContext& executionContext, 02338 XalanNode* context, 02339 int opPos, 02340 eMatchScore& scoreHolder) const; 02341 02342 int 02343 findNodeSet( 02344 XPathExecutionContext& executionContext, 02345 XalanNode* context, 02346 int opPos, 02347 int stepType, 02348 MutableNodeRefList& subQueryResults) const; 02349 02350 int 02351 findRoot( 02352 XPathExecutionContext& executionContext, 02353 XalanNode* context, 02354 int opPos, 02355 int stepType, 02356 MutableNodeRefList& subQueryResults) const; 02357 02358 int 02359 findParent( 02360 XPathExecutionContext& executionContext, 02361 XalanNode* context, 02362 int opPos, 02363 int stepType, 02364 MutableNodeRefList& subQueryResults) const; 02365 02366 int 02367 findSelf( 02368 XPathExecutionContext& executionContext, 02369 XalanNode* context, 02370 int opPos, 02371 int stepType, 02372 MutableNodeRefList& subQueryResults) const; 02373 02374 int 02375 findAncestors( 02376 XPathExecutionContext& executionContext, 02377 XalanNode* context, 02378 int opPos, 02379 int stepType, 02380 MutableNodeRefList& subQueryResults) const; 02381 02382 int 02383 findAncestorsOrSelf( 02384 XPathExecutionContext& executionContext, 02385 XalanNode* context, 02386 int opPos, 02387 int stepType, 02388 MutableNodeRefList& subQueryResults) const; 02389 02390 int 02391 findAttributes( 02392 XPathExecutionContext& executionContext, 02393 XalanNode* context, 02394 int opPos, 02395 int stepType, 02396 MutableNodeRefList& subQueryResults) const; 02397 02398 int 02399 findChildren( 02400 XPathExecutionContext& executionContext, 02401 XalanNode* context, 02402 int opPos, 02403 int stepType, 02404 MutableNodeRefList& subQueryResults) const; 02405 02406 int 02407 findDescendants( 02408 XPathExecutionContext& executionContext, 02409 XalanNode* context, 02410 int opPos, 02411 int stepType, 02412 MutableNodeRefList& subQueryResults) const; 02413 02414 int 02415 findFollowing( 02416 XPathExecutionContext& executionContext, 02417 XalanNode* context, 02418 int opPos, 02419 int stepType, 02420 MutableNodeRefList& subQueryResults) const; 02421 02422 int 02423 findFollowingSiblings( 02424 XPathExecutionContext& executionContext, 02425 XalanNode* context, 02426 int opPos, 02427 int stepType, 02428 MutableNodeRefList& subQueryResults) const; 02429 02430 int 02431 findPreceeding( 02432 XPathExecutionContext& executionContext, 02433 XalanNode* context, 02434 int opPos, 02435 int stepType, 02436 MutableNodeRefList& subQueryResults) const; 02437 02438 int 02439 findPreceedingSiblings( 02440 XPathExecutionContext& executionContext, 02441 XalanNode* context, 02442 int opPos, 02443 int stepType, 02444 MutableNodeRefList& subQueryResults) const; 02445 02446 int 02447 findNamespace( 02448 XPathExecutionContext& executionContext, 02449 XalanNode* context, 02450 int opPos, 02451 int stepType, 02452 MutableNodeRefList& subQueryResults) const; 02453 02454 int 02455 findNodesOnUnknownAxis( 02456 XPathExecutionContext& executionContext, 02457 XalanNode* context, 02458 int opPos, 02459 int stepType, 02460 MutableNodeRefList& subQueryResults) const; 02461 02462 eMatchScore 02463 nodeTest( 02464 XPathExecutionContext& executionContext, 02465 XalanNode* context, 02466 XalanNode::NodeType nodeType, 02467 int opPos, 02468 int argLen, 02469 int stepType) const; 02470 02471 int 02472 predicates( 02473 XPathExecutionContext& executionContext, 02474 int opPos, 02475 MutableNodeRefList& subQueryResults) const; 02476 02477 eMatchScore 02478 handleFoundIndex( 02479 XPathExecutionContext& executionContext, 02480 XalanNode* localContext, 02481 int startOpPos) const; 02482 02483 eMatchScore 02484 handleFoundIndexPositional( 02485 XPathExecutionContext& executionContext, 02486 XalanNode* localContext, 02487 int startOpPos) const; 02488 02489 private: 02490 02491 void 02492 unknownOpCodeError( 02493 XalanNode* context, 02494 XPathExecutionContext& executionContext, 02495 int opPos) const; 02496 02497 void 02498 notNodeSetError( 02499 XalanNode* context, 02500 XPathExecutionContext& executionContext) const; 02501 02502 // Data members... 02503 02509 XPathExpression m_expression; 02510 02514 const LocatorType* m_locator; 02515 02521 bool m_inStylesheet; 02522 02528 static FunctionTableType s_functions; 02529 02530 static const XalanDOMString s_emptyString; 02531 }; 02532 02533 02534 02535 XALAN_CPP_NAMESPACE_END 02536 02537 02538 02539 #endif // XPATH_HEADER_GUARD_1357924680
Doxygen and GraphViz are used to generate this API documentation from the Xalan-C header files.
![]() |
Xalan-C++ XSLT Processor Version 1.7 |
|