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(XPATH_HEADER_GUARD_1357924680) 00017 #define XPATH_HEADER_GUARD_1357924680 00018 00019 00020 00021 // Base header file. Must be first. 00022 #include <xalanc/XPath/XPathDefinitions.hpp> 00023 00024 00025 00026 #include <xalanc/XalanDOM/XalanDOMString.hpp> 00027 00028 00029 00030 #include <xalanc/PlatformSupport/DoubleSupport.hpp> 00031 00032 00033 00034 // Base class header files... 00035 #include <xalanc/XPath/XPathExecutionContext.hpp> 00036 00037 00038 00039 #include <xalanc/XPath/MutableNodeRefList.hpp> 00040 #include <xalanc/XPath/XPathExpression.hpp> 00041 #include <xalanc/XPath/Function.hpp> 00042 #include <xalanc/XPath/XPathFunctionTable.hpp> 00043 00044 00045 00046 XALAN_DECLARE_XERCES_CLASS(Locator) 00047 00048 00049 00050 XALAN_CPP_NAMESPACE_BEGIN 00051 00052 00053 00054 class PrefixResolver; 00055 class XObject; 00056 class XalanElement; 00057 class XalanNode; 00058 class XPathConstructionContext; 00059 00060 00061 00062 class XALAN_XPATH_EXPORT XPath 00063 { 00064 public: 00065 00066 typedef XERCES_CPP_NAMESPACE_QUALIFIER Locator LocatorType; 00067 00068 typedef XPathExpression::OpCodeMapPositionType OpCodeMapPositionType; 00069 typedef XPathExpression::OpCodeMapValueType OpCodeMapValueType; 00070 typedef XPathExpression::TokenQueuePositionType TokenQueuePositionType; 00071 typedef XPathExecutionContext::GetAndReleaseCachedString GetCachedString; 00072 typedef XPathExecutionContext::PrefixResolverSetAndRestore PrefixResolverSetAndRestore; 00073 typedef XPathExecutionContext::CurrentNodePushAndPop CurrentNodePushAndPop; 00074 00075 00076 static const XalanDOMChar PSEUDONAME_ANY[]; 00077 static const XalanDOMChar PSEUDONAME_ROOT[]; 00078 static const XalanDOMChar PSEUDONAME_TEXT[]; 00079 static const XalanDOMChar PSEUDONAME_COMMENT[]; 00080 static const XalanDOMChar PSEUDONAME_PI[]; 00081 static const XalanDOMChar PSEUDONAME_OTHER[]; 00082 static const XalanDOMChar PSEUDONAME_NODE[]; 00083 00084 enum eMatchScore 00085 { 00086 eMatchScoreNone, 00087 eMatchScoreNodeTest, 00088 eMatchScoreNSWild, 00089 eMatchScoreQName, 00090 eMatchScoreOther 00091 }; 00092 00093 class TargetData 00094 { 00095 public: 00096 00097 enum eTargetType { eAttribute, eElement, eAny, eOther }; 00098 00099 TargetData() : 00100 m_string(0), 00101 m_priority(eMatchScoreNone), 00102 m_targetType(eOther) 00103 { 00104 } 00105 00106 TargetData( 00107 const XalanDOMChar* theString, 00108 eMatchScore thePriority, 00109 eTargetType theTargetType) : 00110 m_string(theString), 00111 m_priority(thePriority), 00112 m_targetType(theTargetType) 00113 { 00114 } 00115 00116 const XalanDOMChar* 00117 getString() const 00118 { 00119 return m_string; 00120 } 00121 00122 eMatchScore 00123 getDefaultPriority() const 00124 { 00125 return m_priority; 00126 } 00127 00128 eTargetType 00129 getTargetType() const 00130 { 00131 return m_targetType; 00132 } 00133 00134 private: 00135 00136 const XalanDOMChar* m_string; 00137 00138 eMatchScore m_priority; 00139 00140 eTargetType m_targetType; 00141 }; 00142 00143 typedef XalanVector<TargetData> TargetDataVectorType; 00144 00148 static void 00149 initialize(MemoryManagerType& theManager); 00150 00154 static void 00155 terminate(); 00156 00162 explicit 00163 XPath(MemoryManagerType& theManager, const LocatorType* theLocator = 0); 00164 00165 static XPath* 00166 create(MemoryManagerType& theManager, const LocatorType* theLocator = 0); 00167 00168 MemoryManagerType& 00169 getMemoryManager() 00170 { 00171 return m_expression.getMemoryManager(); 00172 } 00173 ~XPath(); 00174 00178 void 00179 shrink() 00180 { 00181 m_expression.shrink(); 00182 } 00183 00192 const XObjectPtr 00193 execute( 00194 XalanNode* context, 00195 const PrefixResolver& prefixResolver, 00196 XPathExecutionContext& executionContext) const; 00197 00206 void 00207 execute( 00208 XalanNode* context, 00209 const PrefixResolver& prefixResolver, 00210 XPathExecutionContext& executionContext, 00211 bool& result) const; 00212 00221 void 00222 execute( 00223 XalanNode* context, 00224 const PrefixResolver& prefixResolver, 00225 XPathExecutionContext& executionContext, 00226 double& result) const; 00227 00237 void 00238 execute( 00239 XalanNode* context, 00240 const PrefixResolver& prefixResolver, 00241 XPathExecutionContext& executionContext, 00242 XalanDOMString& result) const; 00243 00244 typedef void (FormatterListener::*MemberFunctionPtr)(const XMLCh* const, const unsigned int); 00245 00255 void 00256 execute( 00257 XalanNode* context, 00258 const PrefixResolver& prefixResolver, 00259 XPathExecutionContext& executionContext, 00260 FormatterListener& formatterListener, 00261 MemberFunctionPtr function) const; 00262 00282 const XObjectPtr 00283 execute( 00284 XalanNode* context, 00285 const PrefixResolver& prefixResolver, 00286 XPathExecutionContext& executionContext, 00287 MutableNodeRefList& result) const; 00288 00298 const XObjectPtr 00299 execute( 00300 XalanNode* context, 00301 const PrefixResolver& prefixResolver, 00302 const NodeRefListBase& contextNodeList, 00303 XPathExecutionContext& executionContext) const 00304 { 00305 // Push and pop the context node list... 00306 XPathExecutionContext::ContextNodeListPushAndPop thePushAndPop( 00307 executionContext, 00308 contextNodeList); 00309 00310 return execute(context, prefixResolver, executionContext); 00311 } 00312 00322 void 00323 execute( 00324 XalanNode* context, 00325 const PrefixResolver& prefixResolver, 00326 const NodeRefListBase& contextNodeList, 00327 XPathExecutionContext& executionContext, 00328 bool& result) const 00329 { 00330 // Push and pop the context node list... 00331 XPathExecutionContext::ContextNodeListPushAndPop thePushAndPop( 00332 executionContext, 00333 contextNodeList); 00334 00335 execute(context, prefixResolver, executionContext, result); 00336 } 00337 00347 void 00348 execute( 00349 XalanNode* context, 00350 const PrefixResolver& prefixResolver, 00351 const NodeRefListBase& contextNodeList, 00352 XPathExecutionContext& executionContext, 00353 double& result) const 00354 { 00355 // Push and pop the context node list... 00356 XPathExecutionContext::ContextNodeListPushAndPop thePushAndPop( 00357 executionContext, 00358 contextNodeList); 00359 00360 execute(context, prefixResolver, executionContext, result); 00361 } 00362 00373 void 00374 execute( 00375 XalanNode* context, 00376 const PrefixResolver& prefixResolver, 00377 const NodeRefListBase& contextNodeList, 00378 XPathExecutionContext& executionContext, 00379 XalanDOMString& result) const 00380 { 00381 // Push and pop the context node list... 00382 XPathExecutionContext::ContextNodeListPushAndPop thePushAndPop( 00383 executionContext, 00384 contextNodeList); 00385 00386 execute(context, prefixResolver, executionContext, result); 00387 } 00388 00399 void 00400 execute( 00401 XalanNode* context, 00402 const PrefixResolver& prefixResolver, 00403 const NodeRefListBase& contextNodeList, 00404 XPathExecutionContext& executionContext, 00405 FormatterListener& formatterListener, 00406 MemberFunctionPtr function) const 00407 { 00408 // Push and pop the context node list... 00409 XPathExecutionContext::ContextNodeListPushAndPop thePushAndPop( 00410 executionContext, 00411 contextNodeList); 00412 00413 execute(context, prefixResolver, executionContext, formatterListener, function); 00414 } 00415 00436 const XObjectPtr 00437 execute( 00438 XalanNode* context, 00439 const PrefixResolver& prefixResolver, 00440 const NodeRefListBase& contextNodeList, 00441 XPathExecutionContext& executionContext, 00442 MutableNodeRefList& result) const 00443 { 00444 // Push and pop the context node list... 00445 XPathExecutionContext::ContextNodeListPushAndPop thePushAndPop( 00446 executionContext, 00447 contextNodeList); 00448 00449 return execute(context, prefixResolver, executionContext, result); 00450 } 00451 00461 const XObjectPtr 00462 execute(XPathExecutionContext& executionContext) const 00463 { 00464 assert(executionContext.getCurrentNode() != 0); 00465 assert(executionContext.getPrefixResolver() != 0); 00466 00467 return executeMore( 00468 executionContext.getCurrentNode(), 00469 getInitialOpCodePosition(), 00470 executionContext); 00471 } 00472 00482 void 00483 execute( 00484 XPathExecutionContext& executionContext, 00485 bool& result) const 00486 { 00487 assert(executionContext.getCurrentNode() != 0); 00488 assert(executionContext.getPrefixResolver() != 0); 00489 00490 executeMore( 00491 executionContext.getCurrentNode(), 00492 getInitialOpCodePosition(), 00493 executionContext, 00494 result); 00495 } 00496 00506 void 00507 execute( 00508 XPathExecutionContext& executionContext, 00509 double& result) const 00510 { 00511 assert(executionContext.getCurrentNode() != 0); 00512 assert(executionContext.getPrefixResolver() != 0); 00513 00514 executeMore( 00515 executionContext.getCurrentNode(), 00516 getInitialOpCodePosition(), 00517 executionContext, 00518 result); 00519 } 00520 00531 void 00532 execute( 00533 XPathExecutionContext& executionContext, 00534 XalanDOMString& result) const 00535 { 00536 assert(executionContext.getCurrentNode() != 0); 00537 assert(executionContext.getPrefixResolver() != 0); 00538 00539 executeMore( 00540 executionContext.getCurrentNode(), 00541 getInitialOpCodePosition(), 00542 executionContext, 00543 result); 00544 } 00545 00556 void 00557 execute( 00558 XPathExecutionContext& executionContext, 00559 FormatterListener& formatterListener, 00560 MemberFunctionPtr function) const 00561 { 00562 assert(executionContext.getCurrentNode() != 0); 00563 assert(executionContext.getPrefixResolver() != 0); 00564 00565 executeMore( 00566 executionContext.getCurrentNode(), 00567 getInitialOpCodePosition(), 00568 executionContext, 00569 formatterListener, 00570 function); 00571 } 00572 00593 const XObjectPtr 00594 execute( 00595 XPathExecutionContext& executionContext, 00596 MutableNodeRefList& result) const 00597 { 00598 assert(executionContext.getCurrentNode() != 0); 00599 assert(executionContext.getPrefixResolver() != 0); 00600 00601 return executeMore( 00602 executionContext.getCurrentNode(), 00603 getInitialOpCodePosition(), 00604 executionContext, 00605 result); 00606 } 00607 00618 const XObjectPtr 00619 execute( 00620 const PrefixResolver& prefixResolver, 00621 XPathExecutionContext& executionContext) const 00622 { 00623 assert(executionContext.getCurrentNode() != 0); 00624 00625 // Push and pop the PrefixResolver... 00626 const PrefixResolverSetAndRestore theResolverSetAndRestore( 00627 executionContext, 00628 &prefixResolver); 00629 00630 return executeMore( 00631 executionContext.getCurrentNode(), 00632 getInitialOpCodePosition(), 00633 executionContext); 00634 } 00635 00646 void 00647 execute( 00648 const PrefixResolver& prefixResolver, 00649 XPathExecutionContext& executionContext, 00650 bool& result) const 00651 { 00652 assert(executionContext.getCurrentNode() != 0); 00653 00654 // Push and pop the PrefixResolver... 00655 const PrefixResolverSetAndRestore theResolverSetAndRestore( 00656 executionContext, 00657 &prefixResolver); 00658 00659 executeMore( 00660 executionContext.getCurrentNode(), 00661 getInitialOpCodePosition(), 00662 executionContext, 00663 result); 00664 } 00665 00676 void 00677 execute( 00678 const PrefixResolver& prefixResolver, 00679 XPathExecutionContext& executionContext, 00680 double& result) const 00681 { 00682 assert(executionContext.getCurrentNode() != 0); 00683 00684 // Push and pop the PrefixResolver... 00685 const PrefixResolverSetAndRestore theResolverSetAndRestore( 00686 executionContext, 00687 &prefixResolver); 00688 00689 executeMore( 00690 executionContext.getCurrentNode(), 00691 getInitialOpCodePosition(), 00692 executionContext, 00693 result); 00694 } 00695 00707 void 00708 execute( 00709 const PrefixResolver& prefixResolver, 00710 XPathExecutionContext& executionContext, 00711 XalanDOMString& result) const 00712 { 00713 assert(executionContext.getCurrentNode() != 0); 00714 00715 // Push and pop the PrefixResolver... 00716 const PrefixResolverSetAndRestore theResolverSetAndRestore( 00717 executionContext, 00718 &prefixResolver); 00719 00720 executeMore( 00721 executionContext.getCurrentNode(), 00722 getInitialOpCodePosition(), 00723 executionContext, 00724 result); 00725 } 00726 00735 void 00736 execute( 00737 const PrefixResolver& prefixResolver, 00738 XPathExecutionContext& executionContext, 00739 FormatterListener& formatterListener, 00740 MemberFunctionPtr function) const 00741 { 00742 assert(executionContext.getCurrentNode() != 0); 00743 00744 // Push and pop the PrefixResolver... 00745 const PrefixResolverSetAndRestore theResolverSetAndRestore( 00746 executionContext, 00747 &prefixResolver); 00748 00749 executeMore( 00750 executionContext.getCurrentNode(), 00751 getInitialOpCodePosition(), 00752 executionContext, 00753 formatterListener, 00754 function); 00755 } 00756 00778 XObjectPtr 00779 execute( 00780 const PrefixResolver& prefixResolver, 00781 XPathExecutionContext& executionContext, 00782 MutableNodeRefList& result) const 00783 { 00784 assert(executionContext.getCurrentNode() != 0); 00785 00786 // Push and pop the PrefixResolver... 00787 const PrefixResolverSetAndRestore theResolverSetAndRestore( 00788 executionContext, 00789 &prefixResolver); 00790 00791 return executeMore( 00792 executionContext.getCurrentNode(), 00793 getInitialOpCodePosition(), 00794 executionContext, 00795 result); 00796 } 00797 00803 XPathExpression& 00804 getExpression() 00805 { 00806 return m_expression; 00807 } 00808 00814 const XPathExpression& 00815 getExpression() const 00816 { 00817 return m_expression; 00818 } 00819 00820 static double 00821 getMatchScoreValue(eMatchScore score) 00822 { 00823 switch(score) 00824 { 00825 case eMatchScoreNone: 00826 return DoubleSupport::getNegativeInfinity(); 00827 break; 00828 00829 case eMatchScoreNodeTest: 00830 return -0.5; 00831 break; 00832 00833 case eMatchScoreNSWild: 00834 return -0.25; 00835 break; 00836 00837 case eMatchScoreOther: 00838 return 0.5; 00839 break; 00840 00841 case eMatchScoreQName: 00842 return 0.0; 00843 break; 00844 }; 00845 00846 assert(false); 00847 return 0.0; 00848 } 00849 00857 eMatchScore 00858 getMatchScore( 00859 XalanNode* node, 00860 XPathExecutionContext& executionContext) const; 00861 00870 eMatchScore 00871 getMatchScore( 00872 XalanNode* node, 00873 const PrefixResolver& resolver, 00874 XPathExecutionContext& executionContext) const; 00875 00884 const XObjectPtr 00885 predicate( 00886 XalanNode* context, 00887 OpCodeMapPositionType opPos, 00888 XPathExecutionContext& executionContext) const 00889 { 00890 return executeMore(context, opPos + 2, executionContext); 00891 } 00892 00898 void 00899 getTargetData(TargetDataVectorType& targetData) const; 00900 00907 static void 00908 installFunction( 00909 const XalanDOMString& funcName, 00910 const Function& func) 00911 { 00912 s_functions.InstallFunction(funcName, 00913 func); 00914 } 00915 00922 static void 00923 installFunction( 00924 const XalanDOMChar* funcName, 00925 const Function& func) 00926 { 00927 s_functions.InstallFunction(funcName, 00928 func); 00929 } 00930 00937 static bool 00938 uninstallFunction(const XalanDOMString& funcName) 00939 { 00940 return s_functions.UninstallFunction(funcName); 00941 } 00942 00949 static bool 00950 uninstallFunction(const XalanDOMChar* funcName) 00951 { 00952 return s_functions.UninstallFunction(funcName); 00953 } 00954 00961 static bool 00962 isInstalledFunction(const XalanDOMString& theFunctionName) 00963 { 00964 return s_functions.isInstalledFunction(theFunctionName); 00965 } 00966 00967 typedef XPathFunctionTable FunctionTableType; 00968 00974 static const FunctionTableType& 00975 getFunctionTable() 00976 { 00977 return s_functions; 00978 } 00979 00980 #if defined(XALAN_NO_MEMBER_TEMPLATES) 00981 typedef XPathFunctionTable::InstalledFunctionNameVectorType 00982 InstalledFunctionNameVectorType; 00983 00989 static void 00990 getInstalledFunctionNames(InstalledFunctionNameVectorType& theVector) 00991 { 00992 s_functions.getInstalledFunctionNames(theVector); 00993 } 00994 #else 00995 01000 template<class OutputIteratorType> 01001 static void 01002 getInstalledFunctionNames(OutputIteratorType theIterator) 01003 { 01004 s_functions.getInstalledFunctionNames(theIterator); 01005 } 01006 #endif 01007 01008 static void 01009 destroyTable() 01010 { 01011 s_functions.DestroyTable(); 01012 } 01013 01014 bool 01015 getInStylesheet() const 01016 { 01017 return m_inStylesheet; 01018 } 01019 01020 void 01021 setInStylesheet(bool fValue) 01022 { 01023 m_inStylesheet = fValue; 01024 } 01025 01026 const LocatorType* 01027 getLocator() const 01028 { 01029 return m_locator; 01030 } 01031 01032 void 01033 setLocator(const LocatorType* theLocator) 01034 { 01035 m_locator = theLocator; 01036 } 01037 01038 class NodeTester 01039 { 01040 public: 01041 01042 NodeTester(); 01043 01044 NodeTester(const NodeTester& theSource); 01045 01046 NodeTester( 01047 const XPath& xpath, 01048 XPathExecutionContext& executionContext, 01049 OpCodeMapPositionType opPos, 01050 OpCodeMapValueType argLen, 01051 OpCodeMapValueType stepType); 01052 01053 NodeTester( 01054 XPathConstructionContext& theContext, 01055 const XalanDOMString& theNameTest, 01056 const PrefixResolver& thePrefixResolver, 01057 const LocatorType* theLocator = 0, 01058 eMatchScore* theMatchScore = 0); 01059 01060 NodeTester( 01061 const XalanDOMString& theNamespaceURI, 01062 const XalanDOMString& theLocalName, 01063 eMatchScore* theMatchScore = 0); 01064 01065 eMatchScore 01066 operator()( 01067 const XalanNode& context, 01068 XalanNode::NodeType nodeType) const 01069 { 01070 assert(context.getNodeType() == nodeType); 01071 01072 return (this->*m_testFunction)(context, nodeType); 01073 } 01074 01075 eMatchScore 01076 operator()(const XalanElement& context) const 01077 { 01078 return (this->*m_testFunction2)(context); 01079 } 01080 01081 NodeTester& 01082 operator=(const NodeTester& theRHS) 01083 { 01084 m_executionContext = theRHS.m_executionContext; 01085 m_targetNamespace = theRHS.m_targetNamespace; 01086 m_targetLocalName = theRHS.m_targetLocalName; 01087 m_testFunction = theRHS.m_testFunction; 01088 m_testFunction2 = theRHS.m_testFunction2; 01089 01090 return *this; 01091 } 01092 01093 protected: 01094 01095 eMatchScore 01096 initialize( 01097 XPathConstructionContext& theConstructionContext, 01098 const XalanDOMString& theNameTest, 01099 const PrefixResolver& thePrefixResolver, 01100 const LocatorType* theLocator); 01101 01102 eMatchScore 01103 initialize( 01104 const XalanDOMString& theNamespaceURI, 01105 const XalanDOMString& theLocalName); 01106 01107 private: 01108 01109 01110 typedef eMatchScore (NodeTester::*TestFunctionPtr)(const XalanNode&, XalanNode::NodeType) const; 01111 typedef eMatchScore (NodeTester::*TestFunctionPtr2)(const XalanElement&) const; 01112 01113 01114 eMatchScore 01115 testComment( 01116 const XalanNode& context, 01117 XalanNode::NodeType nodeType) const; 01118 01119 eMatchScore 01120 testText( 01121 const XalanNode& context, 01122 XalanNode::NodeType nodeType) const; 01123 01124 eMatchScore 01125 testPI( 01126 const XalanNode& context, 01127 XalanNode::NodeType nodeType) const; 01128 01129 eMatchScore 01130 testPIName( 01131 const XalanNode& context, 01132 XalanNode::NodeType nodeType) const; 01133 01134 eMatchScore 01135 testNode( 01136 const XalanNode& context, 01137 XalanNode::NodeType nodeType) const; 01138 01139 eMatchScore 01140 testRoot( 01141 const XalanNode& context, 01142 XalanNode::NodeType nodeType) const; 01143 01144 eMatchScore 01145 testAttributeNCName( 01146 const XalanNode& context, 01147 XalanNode::NodeType nodeType) const; 01148 01149 eMatchScore 01150 testAttributeQName( 01151 const XalanNode& context, 01152 XalanNode::NodeType nodeType) const; 01153 01154 eMatchScore 01155 testAttributeNamespaceOnly( 01156 const XalanNode& context, 01157 XalanNode::NodeType nodeType) const; 01158 01159 eMatchScore 01160 testAttributeTotallyWild( 01161 const XalanNode& context, 01162 XalanNode::NodeType nodeType) const; 01163 01164 eMatchScore 01165 testElementNCName( 01166 const XalanNode& context, 01167 XalanNode::NodeType nodeType) const; 01168 01169 eMatchScore 01170 testElementQName( 01171 const XalanNode& context, 01172 XalanNode::NodeType nodeType) const; 01173 01174 eMatchScore 01175 testElementNamespaceOnly( 01176 const XalanNode& context, 01177 XalanNode::NodeType nodeType) const; 01178 01179 eMatchScore 01180 testElementTotallyWild( 01181 const XalanNode& context, 01182 XalanNode::NodeType nodeType) const; 01183 01184 eMatchScore 01185 testElementNCName2(const XalanElement& context) const; 01186 01187 eMatchScore 01188 testElementQName2(const XalanElement& context) const; 01189 01190 eMatchScore 01191 testElementNamespaceOnly2(const XalanElement& context) const; 01192 01193 eMatchScore 01194 testElementTotallyWild2(const XalanElement& context) const; 01195 01196 eMatchScore 01197 testNamespaceNCName( 01198 const XalanNode& context, 01199 XalanNode::NodeType nodeType) const; 01200 01201 eMatchScore 01202 testNamespaceTotallyWild( 01203 const XalanNode& context, 01204 XalanNode::NodeType nodeType) const; 01205 01206 eMatchScore 01207 testDefault( 01208 const XalanNode& context, 01209 XalanNode::NodeType nodeType) const; 01210 01211 eMatchScore 01212 testDefault2(const XalanElement& context) const; 01213 01214 bool 01215 matchLocalName(const XalanNode& context) const; 01216 01217 bool 01218 matchNamespaceURI(const XalanNode& context) const; 01219 01220 bool 01221 matchLocalNameAndNamespaceURI(const XalanNode& context) const; 01222 01223 bool 01224 matchNamespace(const XalanNode& context) const; 01225 01226 bool 01227 shouldStripSourceNode(const XalanText& context) const; 01228 01229 // Data members... 01230 XPathExecutionContext* m_executionContext; 01231 01232 const XalanDOMString* m_targetNamespace; 01233 01234 const XalanDOMString* m_targetLocalName; 01235 01236 TestFunctionPtr m_testFunction; 01237 01238 TestFunctionPtr2 m_testFunction2; 01239 }; 01240 01241 friend class NodeTester; 01242 01243 protected: 01244 01253 const XObjectPtr 01254 locationPath( 01255 XalanNode* context, 01256 OpCodeMapPositionType opPos, 01257 XPathExecutionContext& executionContext) const; 01258 01267 void 01268 locationPath( 01269 XalanNode* context, 01270 OpCodeMapPositionType opPos, 01271 XPathExecutionContext& executionContext, 01272 bool& theResult) const; 01273 01282 void 01283 locationPath( 01284 XalanNode* context, 01285 OpCodeMapPositionType opPos, 01286 XPathExecutionContext& executionContext, 01287 double& theResult) const; 01288 01297 void 01298 locationPath( 01299 XalanNode* context, 01300 OpCodeMapPositionType opPos, 01301 XPathExecutionContext& executionContext, 01302 XalanDOMString& theResult) const; 01303 01313 void 01314 locationPath( 01315 XalanNode* context, 01316 OpCodeMapPositionType opPos, 01317 XPathExecutionContext& executionContext, 01318 FormatterListener& formatterListener, 01319 MemberFunctionPtr function) const; 01320 01329 void 01330 locationPath( 01331 XalanNode* context, 01332 OpCodeMapPositionType opPos, 01333 XPathExecutionContext& executionContext, 01334 MutableNodeRefList& theResult) const 01335 { 01336 step(executionContext, context, opPos + 2, theResult); 01337 } 01338 01347 const XObjectPtr 01348 executeMore( 01349 XalanNode* context, 01350 OpCodeMapPositionType opPos, 01351 XPathExecutionContext& executionContext) const; 01352 01361 void 01362 executeMore( 01363 XalanNode* context, 01364 OpCodeMapPositionType opPos, 01365 XPathExecutionContext& executionContext, 01366 bool& theResult) const; 01367 01376 void 01377 executeMore( 01378 XalanNode* context, 01379 OpCodeMapPositionType opPos, 01380 XPathExecutionContext& executionContext, 01381 double& theResult) const; 01382 01392 void 01393 executeMore( 01394 XalanNode* context, 01395 OpCodeMapPositionType opPos, 01396 XPathExecutionContext& executionContext, 01397 XalanDOMString& theResult) const; 01398 01408 void 01409 executeMore( 01410 XalanNode* context, 01411 OpCodeMapPositionType opPos, 01412 XPathExecutionContext& executionContext, 01413 FormatterListener& formatterListener, 01414 MemberFunctionPtr function) const; 01415 01425 const XObjectPtr 01426 executeMore( 01427 XalanNode* context, 01428 OpCodeMapPositionType opPos, 01429 XPathExecutionContext& executionContext, 01430 MutableNodeRefList& theResult) const; 01431 01438 void 01439 doGetMatchScore( 01440 XalanNode* context, 01441 XPathExecutionContext& executionContext, 01442 eMatchScore& score) const; 01443 01451 bool 01452 Or( 01453 XalanNode* context, 01454 OpCodeMapPositionType opPos, 01455 XPathExecutionContext& executionContext) const; 01456 01464 bool 01465 And( 01466 XalanNode* context, 01467 OpCodeMapPositionType opPos, 01468 XPathExecutionContext& executionContext) const; 01469 01477 bool 01478 notequals( 01479 XalanNode* context, 01480 OpCodeMapPositionType opPos, 01481 XPathExecutionContext& executionContext) const; 01482 01490 bool 01491 equals( 01492 XalanNode* context, 01493 OpCodeMapPositionType opPos, 01494 XPathExecutionContext& executionContext) const; 01495 01503 bool 01504 lte( 01505 XalanNode* context, 01506 OpCodeMapPositionType opPos, 01507 XPathExecutionContext& executionContext) const; 01508 01516 bool 01517 lt( 01518 XalanNode* context, 01519 OpCodeMapPositionType opPos, 01520 XPathExecutionContext& executionContext) const; 01521 01529 bool 01530 gte( 01531 XalanNode* context, 01532 OpCodeMapPositionType opPos, 01533 XPathExecutionContext& executionContext) const; 01534 01542 bool 01543 gt( 01544 XalanNode* context, 01545 OpCodeMapPositionType opPos, 01546 XPathExecutionContext& executionContext) const; 01547 01555 double 01556 plus( 01557 XalanNode* context, 01558 OpCodeMapPositionType opPos, 01559 XPathExecutionContext& executionContext) const; 01560 01569 void 01570 plus( 01571 XalanNode* context, 01572 OpCodeMapPositionType opPos, 01573 XPathExecutionContext& executionContext, 01574 FormatterListener& formatterListener, 01575 MemberFunctionPtr function) const; 01576 01584 double 01585 minus( 01586 XalanNode* context, 01587 OpCodeMapPositionType opPos, 01588 XPathExecutionContext& executionContext) const; 01589 01598 void 01599 minus( 01600 XalanNode* context, 01601 OpCodeMapPositionType opPos, 01602 XPathExecutionContext& executionContext, 01603 FormatterListener& formatterListener, 01604 MemberFunctionPtr function) const; 01605 01613 double 01614 mult( 01615 XalanNode* context, 01616 OpCodeMapPositionType opPos, 01617 XPathExecutionContext& executionContext) const; 01618 01627 void 01628 mult( 01629 XalanNode* context, 01630 OpCodeMapPositionType opPos, 01631 XPathExecutionContext& executionContext, 01632 FormatterListener& formatterListener, 01633 MemberFunctionPtr function) const; 01634 01642 double 01643 div( 01644 XalanNode* context, 01645 OpCodeMapPositionType opPos, 01646 XPathExecutionContext& executionContext) const; 01647 01656 void 01657 div( 01658 XalanNode* context, 01659 OpCodeMapPositionType opPos, 01660 XPathExecutionContext& executionContext, 01661 FormatterListener& formatterListener, 01662 MemberFunctionPtr function) const; 01663 01671 double 01672 mod( 01673 XalanNode* context, 01674 OpCodeMapPositionType opPos, 01675 XPathExecutionContext& executionContext) const; 01676 01685 void 01686 mod( 01687 XalanNode* context, 01688 OpCodeMapPositionType opPos, 01689 XPathExecutionContext& executionContext, 01690 FormatterListener& formatterListener, 01691 MemberFunctionPtr function) const; 01692 01700 double 01701 neg( 01702 XalanNode* context, 01703 OpCodeMapPositionType opPos, 01704 XPathExecutionContext& executionContext) const; 01705 01714 void 01715 neg( 01716 XalanNode* context, 01717 OpCodeMapPositionType opPos, 01718 XPathExecutionContext& executionContext, 01719 FormatterListener& formatterListener, 01720 MemberFunctionPtr function) const; 01721 01729 const XObjectPtr 01730 Union( 01731 XalanNode* context, 01732 OpCodeMapPositionType opPos, 01733 XPathExecutionContext& executionContext) const; 01734 01743 void 01744 Union( 01745 XalanNode* context, 01746 OpCodeMapPositionType opPos, 01747 XPathExecutionContext& executionContext, 01748 bool& result) const; 01749 01758 void 01759 Union( 01760 XalanNode* context, 01761 OpCodeMapPositionType opPos, 01762 XPathExecutionContext& executionContext, 01763 double& result) const; 01764 01773 void 01774 Union( 01775 XalanNode* context, 01776 OpCodeMapPositionType opPos, 01777 XPathExecutionContext& executionContext, 01778 XalanDOMString& result) const; 01779 01789 void 01790 Union( 01791 XalanNode* context, 01792 OpCodeMapPositionType opPos, 01793 XPathExecutionContext& executionContext, 01794 FormatterListener& formatterListener, 01795 MemberFunctionPtr function) const; 01796 01804 void 01805 Union( 01806 XalanNode* context, 01807 OpCodeMapPositionType opPos, 01808 XPathExecutionContext& executionContext, 01809 MutableNodeRefList& result) const; 01810 01817 const XObjectPtr 01818 literal( 01819 OpCodeMapPositionType opPos, 01820 XPathExecutionContext& executionContext) const; 01821 01828 void 01829 literal( 01830 OpCodeMapPositionType opPos, 01831 bool& theResult) const; 01832 01839 void 01840 literal( 01841 OpCodeMapPositionType opPos, 01842 double& theResult) const; 01843 01851 void 01852 literal( 01853 OpCodeMapPositionType opPos, 01854 XalanDOMString& theResult) const; 01855 01862 void 01863 literal( 01864 OpCodeMapPositionType opPos, 01865 FormatterListener& formatterListener, 01866 MemberFunctionPtr function) const; 01867 01874 const XObjectPtr 01875 variable( 01876 OpCodeMapPositionType opPos, 01877 XPathExecutionContext& executionContext) const; 01878 01886 const XObjectPtr 01887 group( 01888 XalanNode* context, 01889 OpCodeMapPositionType opPos, 01890 XPathExecutionContext& executionContext) const 01891 { 01892 return executeMore(context, opPos + 2, executionContext); 01893 } 01894 01902 void 01903 group( 01904 XalanNode* context, 01905 OpCodeMapPositionType opPos, 01906 XPathExecutionContext& executionContext, 01907 bool& theResult) const 01908 { 01909 executeMore(context, opPos + 2, executionContext, theResult); 01910 } 01911 01919 void 01920 group( 01921 XalanNode* context, 01922 OpCodeMapPositionType opPos, 01923 XPathExecutionContext& executionContext, 01924 double& theResult) const 01925 { 01926 executeMore(context, opPos + 2, executionContext, theResult); 01927 } 01928 01936 void 01937 group( 01938 XalanNode* context, 01939 OpCodeMapPositionType opPos, 01940 XPathExecutionContext& executionContext, 01941 XalanDOMString& theResult) const 01942 { 01943 executeMore(context, opPos + 2, executionContext, theResult); 01944 } 01945 01955 void 01956 group( 01957 XalanNode* context, 01958 OpCodeMapPositionType opPos, 01959 XPathExecutionContext& executionContext, 01960 FormatterListener& formatterListener, 01961 MemberFunctionPtr function) const 01962 { 01963 executeMore(context, opPos + 2, executionContext, formatterListener, function); 01964 } 01965 01973 void 01974 group( 01975 XalanNode* context, 01976 OpCodeMapPositionType opPos, 01977 XPathExecutionContext& executionContext, 01978 MutableNodeRefList& theResult) const 01979 { 01980 executeMore(context, opPos + 2, executionContext, theResult); 01981 } 01982 01988 double 01989 numberlit(OpCodeMapPositionType opPos) const; 01990 01996 const XObjectPtr 01997 numberlit( 01998 OpCodeMapPositionType opPos, 01999 XPathExecutionContext& executionContext) const; 02000 02007 void 02008 numberlit( 02009 OpCodeMapPositionType opPos, 02010 bool& theResult) const; 02011 02019 void 02020 numberlit( 02021 OpCodeMapPositionType opPos, 02022 XalanDOMString& theResult) const; 02023 02031 void 02032 numberlit( 02033 OpCodeMapPositionType opPos, 02034 FormatterListener& formatterListener, 02035 MemberFunctionPtr function) const; 02036 02044 const XObjectPtr 02045 runExtFunction( 02046 XalanNode* context, 02047 OpCodeMapPositionType opPos, 02048 XPathExecutionContext& executionContext) const; 02049 02059 const XObjectPtr 02060 extfunction( 02061 XalanNode* context, 02062 OpCodeMapPositionType /* opPos */, 02063 const XalanDOMString& theNamespace, 02064 const XalanDOMString& functionName, 02065 const Function::XObjectArgVectorType& argVec, 02066 XPathExecutionContext& executionContext) const 02067 { 02068 return executionContext.extFunction(theNamespace, 02069 functionName, 02070 context, 02071 argVec, 02072 m_locator); 02073 } 02074 02082 const XObjectPtr 02083 runFunction( 02084 XalanNode* context, 02085 OpCodeMapPositionType opPos, 02086 XPathExecutionContext& executionContext) const; 02087 02096 const XObjectPtr 02097 function( 02098 XalanNode* context, 02099 OpCodeMapValueType funcID, 02100 const Function::XObjectArgVectorType& argVec, 02101 XPathExecutionContext& executionContext) const 02102 { 02103 return s_functions[funcID].execute(executionContext, context, argVec, m_locator); 02104 } 02105 02113 double 02114 functionPosition( 02115 XalanNode* context, 02116 XPathExecutionContext& executionContext) const 02117 { 02118 assert(context != 0); 02119 02120 return executionContext.getContextNodeListPosition(*context); 02121 } 02122 02129 double 02130 functionLast(XPathExecutionContext& executionContext) const 02131 { 02132 return executionContext.getContextNodeListLength(); 02133 } 02134 02143 double 02144 functionCount( 02145 XalanNode* context, 02146 OpCodeMapPositionType opPos, 02147 XPathExecutionContext& executionContext) const; 02148 02157 bool 02158 functionNot( 02159 XalanNode* context, 02160 OpCodeMapPositionType opPos, 02161 XPathExecutionContext& executionContext) const 02162 { 02163 assert(context != 0); 02164 02165 return !functionBoolean(context, opPos, executionContext); 02166 } 02167 02176 bool 02177 functionBoolean( 02178 XalanNode* context, 02179 OpCodeMapPositionType opPos, 02180 XPathExecutionContext& executionContext) const 02181 { 02182 assert(context != 0); 02183 02184 bool result; 02185 02186 executeMore(context, opPos + 2, executionContext, result); 02187 02188 return result; 02189 } 02190 02197 const XalanDOMString& 02198 functionName(XalanNode* context) const 02199 { 02200 assert(context != 0); 02201 02202 return DOMServices::getNameOfNode(*context); 02203 } 02204 02213 const XalanDOMString& 02214 functionName( 02215 XalanNode* context, 02216 OpCodeMapPositionType opPos, 02217 XPathExecutionContext& executionContext) const; 02218 02225 const XalanDOMString& 02226 functionLocalName(XalanNode* context) const; 02227 02236 const XalanDOMString& 02237 functionLocalName( 02238 XalanNode* context, 02239 OpCodeMapPositionType opPos, 02240 XPathExecutionContext& executionContext) const; 02241 02249 double 02250 functionNumber( 02251 XalanNode* context, 02252 XPathExecutionContext& executionContext) const 02253 { 02254 assert(context != 0); 02255 02256 return XObject::number(executionContext, *context); 02257 } 02258 02267 double 02268 functionNumber( 02269 XalanNode* context, 02270 OpCodeMapPositionType opPos, 02271 XPathExecutionContext& executionContext) const 02272 { 02273 double result; 02274 02275 executeMore(context, opPos + 2, executionContext, result); 02276 02277 return result; 02278 } 02279 02288 double 02289 functionFloor( 02290 XalanNode* context, 02291 OpCodeMapPositionType opPos, 02292 XPathExecutionContext& executionContext) const 02293 { 02294 return DoubleSupport::floor(functionNumber(context, opPos, executionContext)); 02295 } 02296 02305 double 02306 functionCeiling( 02307 XalanNode* context, 02308 OpCodeMapPositionType opPos, 02309 XPathExecutionContext& executionContext) const 02310 { 02311 return DoubleSupport::ceiling(functionNumber(context, opPos, executionContext)); 02312 } 02313 02322 double 02323 functionRound( 02324 XalanNode* context, 02325 OpCodeMapPositionType opPos, 02326 XPathExecutionContext& executionContext) const 02327 { 02328 return DoubleSupport::round(functionNumber(context, opPos, executionContext)); 02329 } 02330 02337 double 02338 functionStringLength(XalanNode* context) const; 02339 02348 double 02349 functionStringLength( 02350 XalanNode* context, 02351 OpCodeMapPositionType opPos, 02352 XPathExecutionContext& executionContext) const; 02353 02362 double 02363 functionSum( 02364 XalanNode* context, 02365 OpCodeMapPositionType opPos, 02366 XPathExecutionContext& executionContext) const; 02367 02375 double 02376 getNumericOperand( 02377 XalanNode* context, 02378 OpCodeMapPositionType opPos, 02379 XPathExecutionContext& executionContext) const; 02380 02381 private: 02382 02383 // These are not implemented... 02384 XPath(const XPath&); 02385 02386 XPath& 02387 operator=(const XPath&); 02388 02389 bool 02390 operator==(const XPath&) const; 02391 02392 // Default vector allocation sizes. 02393 enum 02394 { 02395 eDefaultTargetDataSize = 5 02396 }; 02397 02398 OpCodeMapPositionType 02399 getInitialOpCodePosition() const 02400 { 02401 #if defined(XALAN_XPATH_EXPRESSION_USE_ITERATORS) 02402 assert(m_expression.getOpCodeMapValue(0) == XPathExpression::eOP_XPATH); 02403 #else 02404 assert(m_expression.getOpCodeMapValue( 02405 m_expression.getInitialOpCodePosition()) == XPathExpression::eOP_XPATH); 02406 #endif 02407 return m_expression.getInitialOpCodePosition() + 2; 02408 } 02409 02410 eMatchScore 02411 locationPathPattern( 02412 XPathExecutionContext& executionContext, 02413 XalanNode& context, 02414 OpCodeMapPositionType opPos) const; 02415 02416 protected: 02417 02418 void 02419 step( 02420 XPathExecutionContext& executionContext, 02421 XalanNode* context, 02422 OpCodeMapPositionType opPos, 02423 MutableNodeRefList& queryResults) const; 02424 02435 XalanNode* 02436 stepPattern( 02437 XPathExecutionContext& executionContext, 02438 XalanNode* context, 02439 OpCodeMapPositionType opPos, 02440 eMatchScore& scoreHolder) const; 02441 02442 OpCodeMapPositionType 02443 findNodeSet( 02444 XPathExecutionContext& executionContext, 02445 XalanNode* context, 02446 OpCodeMapPositionType opPos, 02447 OpCodeMapValueType stepType, 02448 MutableNodeRefList& subQueryResults) const; 02449 02450 OpCodeMapPositionType 02451 findRoot( 02452 XPathExecutionContext& executionContext, 02453 XalanNode* context, 02454 OpCodeMapPositionType opPos, 02455 OpCodeMapValueType stepType, 02456 MutableNodeRefList& subQueryResults) const; 02457 02458 OpCodeMapPositionType 02459 findParent( 02460 XPathExecutionContext& executionContext, 02461 XalanNode* context, 02462 OpCodeMapPositionType opPos, 02463 OpCodeMapValueType stepType, 02464 MutableNodeRefList& subQueryResults) const; 02465 02466 OpCodeMapPositionType 02467 findSelf( 02468 XPathExecutionContext& executionContext, 02469 XalanNode* context, 02470 OpCodeMapPositionType opPos, 02471 OpCodeMapValueType stepType, 02472 MutableNodeRefList& subQueryResults) const; 02473 02474 OpCodeMapPositionType 02475 findAncestors( 02476 XPathExecutionContext& executionContext, 02477 XalanNode* context, 02478 OpCodeMapPositionType opPos, 02479 OpCodeMapValueType stepType, 02480 MutableNodeRefList& subQueryResults) const; 02481 02482 OpCodeMapPositionType 02483 findAncestorsOrSelf( 02484 XPathExecutionContext& executionContext, 02485 XalanNode* context, 02486 OpCodeMapPositionType opPos, 02487 OpCodeMapValueType stepType, 02488 MutableNodeRefList& subQueryResults) const; 02489 02490 OpCodeMapPositionType 02491 findAttributes( 02492 XPathExecutionContext& executionContext, 02493 XalanNode* context, 02494 OpCodeMapPositionType opPos, 02495 OpCodeMapValueType stepType, 02496 MutableNodeRefList& subQueryResults) const; 02497 02498 OpCodeMapPositionType 02499 findChildren( 02500 XPathExecutionContext& executionContext, 02501 XalanNode* context, 02502 OpCodeMapPositionType opPos, 02503 OpCodeMapValueType stepType, 02504 MutableNodeRefList& subQueryResults) const; 02505 02506 OpCodeMapPositionType 02507 findDescendants( 02508 XPathExecutionContext& executionContext, 02509 XalanNode* context, 02510 OpCodeMapPositionType opPos, 02511 OpCodeMapValueType stepType, 02512 MutableNodeRefList& subQueryResults) const; 02513 02514 OpCodeMapPositionType 02515 findFollowing( 02516 XPathExecutionContext& executionContext, 02517 XalanNode* context, 02518 OpCodeMapPositionType opPos, 02519 OpCodeMapValueType stepType, 02520 MutableNodeRefList& subQueryResults) const; 02521 02522 OpCodeMapPositionType 02523 findFollowingSiblings( 02524 XPathExecutionContext& executionContext, 02525 XalanNode* context, 02526 OpCodeMapPositionType opPos, 02527 OpCodeMapValueType stepType, 02528 MutableNodeRefList& subQueryResults) const; 02529 02530 OpCodeMapPositionType 02531 findPreceeding( 02532 XPathExecutionContext& executionContext, 02533 XalanNode* context, 02534 OpCodeMapPositionType opPos, 02535 OpCodeMapValueType stepType, 02536 MutableNodeRefList& subQueryResults) const; 02537 02538 OpCodeMapPositionType 02539 findPreceedingSiblings( 02540 XPathExecutionContext& executionContext, 02541 XalanNode* context, 02542 OpCodeMapPositionType opPos, 02543 OpCodeMapValueType stepType, 02544 MutableNodeRefList& subQueryResults) const; 02545 02546 OpCodeMapPositionType 02547 findNamespace( 02548 XPathExecutionContext& executionContext, 02549 XalanNode* context, 02550 OpCodeMapPositionType opPos, 02551 OpCodeMapValueType stepType, 02552 MutableNodeRefList& subQueryResults) const; 02553 02554 OpCodeMapPositionType 02555 findNodesOnUnknownAxis( 02556 XPathExecutionContext& executionContext, 02557 XalanNode* context, 02558 OpCodeMapPositionType opPos, 02559 OpCodeMapValueType stepType, 02560 MutableNodeRefList& subQueryResults) const; 02561 02562 #if !defined(NDEBUG) 02563 eMatchScore 02564 nodeTest( 02565 XPathExecutionContext& executionContext, 02566 XalanNode* context, 02567 XalanNode::NodeType nodeType, 02568 OpCodeMapPositionType opPos, 02569 OpCodeMapValueType argLen, 02570 OpCodeMapValueType stepType) const; 02571 #endif 02572 02573 OpCodeMapPositionType 02574 predicates( 02575 XPathExecutionContext& executionContext, 02576 OpCodeMapPositionType opPos, 02577 MutableNodeRefList& subQueryResults) const; 02578 02579 eMatchScore 02580 handleFoundIndex( 02581 XPathExecutionContext& executionContext, 02582 XalanNode* localContext, 02583 OpCodeMapPositionType startOpPos) const; 02584 02585 eMatchScore 02586 handleFoundIndexPositional( 02587 XPathExecutionContext& executionContext, 02588 XalanNode* localContext, 02589 OpCodeMapPositionType startOpPos) const; 02590 02591 private: 02592 02593 void 02594 unknownOpCodeError( 02595 XalanNode* context, 02596 XPathExecutionContext& executionContext, 02597 OpCodeMapPositionType opPos) const; 02598 02599 void 02600 notNodeSetError( 02601 XalanNode* context, 02602 XPathExecutionContext& executionContext) const; 02603 02604 // Data members... 02605 02611 XPathExpression m_expression; 02612 02616 const LocatorType* m_locator; 02617 02623 bool m_inStylesheet; 02624 02630 static FunctionTableType s_functions; 02631 02632 static const XalanDOMString s_emptyString; 02633 }; 02634 02635 02636 02637 XALAN_CPP_NAMESPACE_END 02638 02639 02640 02641 #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.10 |
|