Xalan-C++ API Documentation

The Xalan C++ XSLT Processor Version 1.8

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

XPath.hpp

Go to the documentation of this file.
00001 /* 00002 * Copyright 1999-2004 The Apache Software Foundation. 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 #if !defined(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 00072 static const XalanDOMChar PSEUDONAME_ANY[]; 00073 static const XalanDOMChar PSEUDONAME_ROOT[]; 00074 static const XalanDOMChar PSEUDONAME_TEXT[]; 00075 static const XalanDOMChar PSEUDONAME_COMMENT[]; 00076 static const XalanDOMChar PSEUDONAME_PI[]; 00077 static const XalanDOMChar PSEUDONAME_OTHER[]; 00078 static const XalanDOMChar PSEUDONAME_NODE[]; 00079 00080 enum eMatchScore 00081 { 00082 eMatchScoreNone, 00083 eMatchScoreNodeTest, 00084 eMatchScoreNSWild, 00085 eMatchScoreQName, 00086 eMatchScoreOther 00087 }; 00088 00089 class TargetData 00090 { 00091 public: 00092 00093 enum eTargetType { eAttribute, eElement, eAny, eOther }; 00094 00095 TargetData() : 00096 m_string(0), 00097 m_priority(eMatchScoreNone), 00098 m_targetType(eOther) 00099 { 00100 } 00101 00102 TargetData( 00103 const XalanDOMChar* theString, 00104 eMatchScore thePriority, 00105 eTargetType theTargetType) : 00106 m_string(theString), 00107 m_priority(thePriority), 00108 m_targetType(theTargetType) 00109 { 00110 } 00111 00112 const XalanDOMChar* 00113 getString() const 00114 { 00115 return m_string; 00116 } 00117 00118 eMatchScore 00119 getDefaultPriority() const 00120 { 00121 return m_priority; 00122 } 00123 00124 eTargetType 00125 getTargetType() const 00126 { 00127 return m_targetType; 00128 } 00129 00130 private: 00131 00132 const XalanDOMChar* m_string; 00133 00134 eMatchScore m_priority; 00135 00136 eTargetType m_targetType; 00137 }; 00138 00139 #if defined(XALAN_NO_STD_NAMESPACE) 00140 typedef vector<TargetData> TargetDataVectorType; 00141 #else 00142 typedef std::vector<TargetData> TargetDataVectorType; 00143 #endif 00144 00145 00149 static void 00150 initialize(); 00151 00155 static void 00156 terminate(); 00157 00163 explicit 00164 XPath(const LocatorType* theLocator = 0); 00165 00166 ~XPath(); 00167 00171 void 00172 shrink() 00173 { 00174 m_expression.shrink(); 00175 } 00176 00185 const XObjectPtr 00186 execute( 00187 XalanNode* context, 00188 const PrefixResolver& prefixResolver, 00189 XPathExecutionContext& executionContext) const; 00190 00199 void 00200 execute( 00201 XalanNode* context, 00202 const PrefixResolver& prefixResolver, 00203 XPathExecutionContext& executionContext, 00204 bool& result) const; 00205 00214 void 00215 execute( 00216 XalanNode* context, 00217 const PrefixResolver& prefixResolver, 00218 XPathExecutionContext& executionContext, 00219 double& result) const; 00220 00230 void 00231 execute( 00232 XalanNode* context, 00233 const PrefixResolver& prefixResolver, 00234 XPathExecutionContext& executionContext, 00235 XalanDOMString& result) const; 00236 00237 typedef void (FormatterListener::*MemberFunctionPtr)(const XMLCh* const, const unsigned int); 00238 00248 void 00249 execute( 00250 XalanNode* context, 00251 const PrefixResolver& prefixResolver, 00252 XPathExecutionContext& executionContext, 00253 FormatterListener& formatterListener, 00254 MemberFunctionPtr function) const; 00255 00275 const XObjectPtr 00276 execute( 00277 XalanNode* context, 00278 const PrefixResolver& prefixResolver, 00279 XPathExecutionContext& executionContext, 00280 MutableNodeRefList& result) const; 00281 00291 const XObjectPtr 00292 execute( 00293 XalanNode* context, 00294 const PrefixResolver& prefixResolver, 00295 const NodeRefListBase& contextNodeList, 00296 XPathExecutionContext& executionContext) const 00297 { 00298 // Push and pop the context node list... 00299 XPathExecutionContext::ContextNodeListPushAndPop thePushAndPop( 00300 executionContext, 00301 contextNodeList); 00302 00303 return execute(context, prefixResolver, executionContext); 00304 } 00305 00315 void 00316 execute( 00317 XalanNode* context, 00318 const PrefixResolver& prefixResolver, 00319 const NodeRefListBase& contextNodeList, 00320 XPathExecutionContext& executionContext, 00321 bool& result) const 00322 { 00323 // Push and pop the context node list... 00324 XPathExecutionContext::ContextNodeListPushAndPop thePushAndPop( 00325 executionContext, 00326 contextNodeList); 00327 00328 execute(context, prefixResolver, executionContext, result); 00329 } 00330 00340 void 00341 execute( 00342 XalanNode* context, 00343 const PrefixResolver& prefixResolver, 00344 const NodeRefListBase& contextNodeList, 00345 XPathExecutionContext& executionContext, 00346 double& result) const 00347 { 00348 // Push and pop the context node list... 00349 XPathExecutionContext::ContextNodeListPushAndPop thePushAndPop( 00350 executionContext, 00351 contextNodeList); 00352 00353 execute(context, prefixResolver, executionContext, result); 00354 } 00355 00366 void 00367 execute( 00368 XalanNode* context, 00369 const PrefixResolver& prefixResolver, 00370 const NodeRefListBase& contextNodeList, 00371 XPathExecutionContext& executionContext, 00372 XalanDOMString& result) const 00373 { 00374 // Push and pop the context node list... 00375 XPathExecutionContext::ContextNodeListPushAndPop thePushAndPop( 00376 executionContext, 00377 contextNodeList); 00378 00379 execute(context, prefixResolver, executionContext, result); 00380 } 00381 00392 void 00393 execute( 00394 XalanNode* context, 00395 const PrefixResolver& prefixResolver, 00396 const NodeRefListBase& contextNodeList, 00397 XPathExecutionContext& executionContext, 00398 FormatterListener& formatterListener, 00399 MemberFunctionPtr function) const 00400 { 00401 // Push and pop the context node list... 00402 XPathExecutionContext::ContextNodeListPushAndPop thePushAndPop( 00403 executionContext, 00404 contextNodeList); 00405 00406 execute(context, prefixResolver, executionContext, formatterListener, function); 00407 } 00408 00429 const XObjectPtr 00430 execute( 00431 XalanNode* context, 00432 const PrefixResolver& prefixResolver, 00433 const NodeRefListBase& contextNodeList, 00434 XPathExecutionContext& executionContext, 00435 MutableNodeRefList& result) const 00436 { 00437 // Push and pop the context node list... 00438 XPathExecutionContext::ContextNodeListPushAndPop thePushAndPop( 00439 executionContext, 00440 contextNodeList); 00441 00442 return execute(context, prefixResolver, executionContext, result); 00443 } 00444 00454 const XObjectPtr 00455 execute(XPathExecutionContext& executionContext) const 00456 { 00457 assert(executionContext.getCurrentNode() != 0); 00458 assert(executionContext.getPrefixResolver() != 0); 00459 00460 return executeMore( 00461 executionContext.getCurrentNode(), 00462 m_expression.getInitialOpCodePosition(), 00463 executionContext); 00464 } 00465 00475 void 00476 execute( 00477 XPathExecutionContext& executionContext, 00478 bool& result) const 00479 { 00480 assert(executionContext.getCurrentNode() != 0); 00481 assert(executionContext.getPrefixResolver() != 0); 00482 00483 executeMore( 00484 executionContext.getCurrentNode(), 00485 m_expression.getInitialOpCodePosition(), 00486 executionContext, 00487 result); 00488 } 00489 00499 void 00500 execute( 00501 XPathExecutionContext& executionContext, 00502 double& result) const 00503 { 00504 assert(executionContext.getCurrentNode() != 0); 00505 assert(executionContext.getPrefixResolver() != 0); 00506 00507 executeMore( 00508 executionContext.getCurrentNode(), 00509 m_expression.getInitialOpCodePosition(), 00510 executionContext, 00511 result); 00512 } 00513 00524 void 00525 execute( 00526 XPathExecutionContext& executionContext, 00527 XalanDOMString& result) const 00528 { 00529 assert(executionContext.getCurrentNode() != 0); 00530 assert(executionContext.getPrefixResolver() != 0); 00531 00532 executeMore( 00533 executionContext.getCurrentNode(), 00534 m_expression.getInitialOpCodePosition(), 00535 executionContext, 00536 result); 00537 } 00538 00549 void 00550 execute( 00551 XPathExecutionContext& executionContext, 00552 FormatterListener& formatterListener, 00553 MemberFunctionPtr function) const 00554 { 00555 assert(executionContext.getCurrentNode() != 0); 00556 assert(executionContext.getPrefixResolver() != 0); 00557 00558 executeMore( 00559 executionContext.getCurrentNode(), 00560 m_expression.getInitialOpCodePosition(), 00561 executionContext, 00562 formatterListener, 00563 function); 00564 } 00565 00586 const XObjectPtr 00587 execute( 00588 XPathExecutionContext& executionContext, 00589 MutableNodeRefList& result) const 00590 { 00591 assert(executionContext.getCurrentNode() != 0); 00592 assert(executionContext.getPrefixResolver() != 0); 00593 00594 return executeMore( 00595 executionContext.getCurrentNode(), 00596 m_expression.getInitialOpCodePosition(), 00597 executionContext, 00598 result); 00599 } 00600 00611 const XObjectPtr 00612 execute( 00613 const PrefixResolver& prefixResolver, 00614 XPathExecutionContext& executionContext) const 00615 { 00616 assert(executionContext.getCurrentNode() != 0); 00617 00618 // Push and pop the PrefixResolver... 00619 const XPathExecutionContext::PrefixResolverSetAndRestore theResolverSetAndRestore( 00620 executionContext, 00621 &prefixResolver); 00622 00623 return executeMore( 00624 executionContext.getCurrentNode(), 00625 m_expression.getInitialOpCodePosition(), 00626 executionContext); 00627 } 00628 00639 void 00640 execute( 00641 const PrefixResolver& prefixResolver, 00642 XPathExecutionContext& executionContext, 00643 bool& result) const 00644 { 00645 assert(executionContext.getCurrentNode() != 0); 00646 00647 // Push and pop the PrefixResolver... 00648 const XPathExecutionContext::PrefixResolverSetAndRestore theResolverSetAndRestore( 00649 executionContext, 00650 &prefixResolver); 00651 00652 executeMore( 00653 executionContext.getCurrentNode(), 00654 m_expression.getInitialOpCodePosition(), 00655 executionContext, 00656 result); 00657 } 00658 00669 void 00670 execute( 00671 const PrefixResolver& prefixResolver, 00672 XPathExecutionContext& executionContext, 00673 double& result) const 00674 { 00675 assert(executionContext.getCurrentNode() != 0); 00676 00677 // Push and pop the PrefixResolver... 00678 const XPathExecutionContext::PrefixResolverSetAndRestore theResolverSetAndRestore( 00679 executionContext, 00680 &prefixResolver); 00681 00682 executeMore( 00683 executionContext.getCurrentNode(), 00684 m_expression.getInitialOpCodePosition(), 00685 executionContext, 00686 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 const XPathExecutionContext::PrefixResolverSetAndRestore theResolverSetAndRestore( 00710 executionContext, 00711 &prefixResolver); 00712 00713 executeMore( 00714 executionContext.getCurrentNode(), 00715 m_expression.getInitialOpCodePosition(), 00716 executionContext, 00717 result); 00718 } 00719 00728 void 00729 execute( 00730 const PrefixResolver& prefixResolver, 00731 XPathExecutionContext& executionContext, 00732 FormatterListener& formatterListener, 00733 MemberFunctionPtr function) const 00734 { 00735 assert(executionContext.getCurrentNode() != 0); 00736 00737 // Push and pop the PrefixResolver... 00738 const XPathExecutionContext::PrefixResolverSetAndRestore theResolverSetAndRestore( 00739 executionContext, 00740 &prefixResolver); 00741 00742 executeMore( 00743 executionContext.getCurrentNode(), 00744 m_expression.getInitialOpCodePosition(), 00745 executionContext, 00746 formatterListener, 00747 function); 00748 } 00749 00771 XObjectPtr 00772 execute( 00773 const PrefixResolver& prefixResolver, 00774 XPathExecutionContext& executionContext, 00775 MutableNodeRefList& result) const 00776 { 00777 assert(executionContext.getCurrentNode() != 0); 00778 00779 // Push and pop the PrefixResolver... 00780 const XPathExecutionContext::PrefixResolverSetAndRestore theResolverSetAndRestore( 00781 executionContext, 00782 &prefixResolver); 00783 00784 return executeMore( 00785 executionContext.getCurrentNode(), 00786 m_expression.getInitialOpCodePosition(), 00787 executionContext, 00788 result); 00789 } 00790 00796 XPathExpression& 00797 getExpression() 00798 { 00799 return m_expression; 00800 } 00801 00807 const XPathExpression& 00808 getExpression() const 00809 { 00810 return m_expression; 00811 } 00812 00813 static double 00814 getMatchScoreValue(eMatchScore score) 00815 { 00816 switch(score) 00817 { 00818 case eMatchScoreNone: 00819 return DoubleSupport::getNegativeInfinity(); 00820 break; 00821 00822 case eMatchScoreNodeTest: 00823 return -0.5; 00824 break; 00825 00826 case eMatchScoreNSWild: 00827 return -0.25; 00828 break; 00829 00830 case eMatchScoreOther: 00831 return 0.5; 00832 break; 00833 00834 case eMatchScoreQName: 00835 return 0.0; 00836 break; 00837 }; 00838 00839 assert(false); 00840 return 0.0; 00841 } 00842 00850 eMatchScore 00851 getMatchScore( 00852 XalanNode* node, 00853 XPathExecutionContext& executionContext) const; 00854 00863 eMatchScore 00864 getMatchScore( 00865 XalanNode* node, 00866 const PrefixResolver& resolver, 00867 XPathExecutionContext& executionContext) const; 00868 00877 const XObjectPtr 00878 predicate( 00879 XalanNode* context, 00880 OpCodeMapPositionType opPos, 00881 XPathExecutionContext& executionContext) const 00882 { 00883 return executeMore(context, opPos + 2, executionContext); 00884 } 00885 00891 void 00892 getTargetData(TargetDataVectorType& targetData) const; 00893 00900 static void 00901 installFunction( 00902 const XalanDOMString& funcName, 00903 const Function& func) 00904 { 00905 s_functions.InstallFunction(funcName, 00906 func); 00907 } 00908 00915 static void 00916 installFunction( 00917 const XalanDOMChar* funcName, 00918 const Function& func) 00919 { 00920 s_functions.InstallFunction(funcName, 00921 func); 00922 } 00923 00930 static bool 00931 uninstallFunction(const XalanDOMString& funcName) 00932 { 00933 return s_functions.UninstallFunction(funcName); 00934 } 00935 00942 static bool 00943 uninstallFunction(const XalanDOMChar* funcName) 00944 { 00945 return s_functions.UninstallFunction(funcName); 00946 } 00947 00954 static bool 00955 isInstalledFunction(const XalanDOMString& theFunctionName) 00956 { 00957 return s_functions.isInstalledFunction(theFunctionName); 00958 } 00959 00960 typedef XPathFunctionTable FunctionTableType; 00961 00967 static const FunctionTableType& 00968 getFunctionTable() 00969 { 00970 return s_functions; 00971 } 00972 00973 #if defined(XALAN_NO_MEMBER_TEMPLATES) 00974 typedef XPathFunctionTable::InstalledFunctionNameVectorType 00975 InstalledFunctionNameVectorType; 00976 00982 static void 00983 getInstalledFunctionNames(InstalledFunctionNameVectorType& theVector) 00984 { 00985 s_functions.getInstalledFunctionNames(theVector); 00986 } 00987 #else 00988 00993 template<class OutputIteratorType> 00994 static void 00995 getInstalledFunctionNames(OutputIteratorType theIterator) 00996 { 00997 s_functions.getInstalledFunctionNames(theIterator); 00998 } 00999 #endif 01000 01001 static void 01002 destroyTable() 01003 { 01004 s_functions.DestroyTable(); 01005 } 01006 01007 bool 01008 getInStylesheet() const 01009 { 01010 return m_inStylesheet; 01011 } 01012 01013 void 01014 setInStylesheet(bool fValue) 01015 { 01016 m_inStylesheet = fValue; 01017 } 01018 01019 const LocatorType* 01020 getLocator() const 01021 { 01022 return m_locator; 01023 } 01024 01025 void 01026 setLocator(const LocatorType* theLocator) 01027 { 01028 m_locator = theLocator; 01029 } 01030 01031 class NodeTester 01032 { 01033 public: 01034 01035 NodeTester(); 01036 01037 NodeTester(const NodeTester& theSource); 01038 01039 NodeTester( 01040 const XPath& xpath, 01041 XPathExecutionContext& executionContext, 01042 OpCodeMapPositionType opPos, 01043 OpCodeMapValueType argLen, 01044 OpCodeMapValueType stepType); 01045 01046 NodeTester( 01047 XPathConstructionContext& theContext, 01048 const XalanDOMString& theNameTest, 01049 const PrefixResolver& thePrefixResolver, 01050 const LocatorType* theLocator = 0, 01051 eMatchScore* theMatchScore = 0); 01052 01053 NodeTester( 01054 const XalanDOMString& theNamespaceURI, 01055 const XalanDOMString& theLocalName, 01056 eMatchScore* theMatchScore = 0); 01057 01058 eMatchScore 01059 operator()( 01060 const XalanNode& context, 01061 XalanNode::NodeType nodeType) const 01062 { 01063 assert(context.getNodeType() == nodeType); 01064 01065 return (this->*m_testFunction)(context, nodeType); 01066 } 01067 01068 eMatchScore 01069 operator()(const XalanElement& context) const 01070 { 01071 return (this->*m_testFunction2)(context); 01072 } 01073 01074 NodeTester& 01075 operator=(const NodeTester& theRHS) 01076 { 01077 m_executionContext = theRHS.m_executionContext; 01078 m_targetNamespace = theRHS.m_targetNamespace; 01079 m_targetLocalName = theRHS.m_targetLocalName; 01080 m_testFunction = theRHS.m_testFunction; 01081 m_testFunction2 = theRHS.m_testFunction2; 01082 01083 return *this; 01084 } 01085 01086 protected: 01087 01088 eMatchScore 01089 initialize( 01090 XPathConstructionContext& theConstructionContext, 01091 const XalanDOMString& theNameTest, 01092 const PrefixResolver& thePrefixResolver, 01093 const LocatorType* theLocator); 01094 01095 eMatchScore 01096 initialize( 01097 const XalanDOMString& theNamespaceURI, 01098 const XalanDOMString& theLocalName); 01099 01100 private: 01101 01102 01103 typedef eMatchScore (NodeTester::*TestFunctionPtr)(const XalanNode&, XalanNode::NodeType) const; 01104 typedef eMatchScore (NodeTester::*TestFunctionPtr2)(const XalanElement&) const; 01105 01106 01107 eMatchScore 01108 testComment( 01109 const XalanNode& context, 01110 XalanNode::NodeType nodeType) const; 01111 01112 eMatchScore 01113 testText( 01114 const XalanNode& context, 01115 XalanNode::NodeType nodeType) const; 01116 01117 eMatchScore 01118 testPI( 01119 const XalanNode& context, 01120 XalanNode::NodeType nodeType) const; 01121 01122 eMatchScore 01123 testPIName( 01124 const XalanNode& context, 01125 XalanNode::NodeType nodeType) const; 01126 01127 eMatchScore 01128 testNode( 01129 const XalanNode& context, 01130 XalanNode::NodeType nodeType) const; 01131 01132 eMatchScore 01133 testRoot( 01134 const XalanNode& context, 01135 XalanNode::NodeType nodeType) const; 01136 01137 eMatchScore 01138 testAttributeNCName( 01139 const XalanNode& context, 01140 XalanNode::NodeType nodeType) const; 01141 01142 eMatchScore 01143 testAttributeQName( 01144 const XalanNode& context, 01145 XalanNode::NodeType nodeType) const; 01146 01147 eMatchScore 01148 testAttributeNamespaceOnly( 01149 const XalanNode& context, 01150 XalanNode::NodeType nodeType) const; 01151 01152 eMatchScore 01153 testAttributeTotallyWild( 01154 const XalanNode& context, 01155 XalanNode::NodeType nodeType) const; 01156 01157 eMatchScore 01158 testElementNCName( 01159 const XalanNode& context, 01160 XalanNode::NodeType nodeType) const; 01161 01162 eMatchScore 01163 testElementQName( 01164 const XalanNode& context, 01165 XalanNode::NodeType nodeType) const; 01166 01167 eMatchScore 01168 testElementNamespaceOnly( 01169 const XalanNode& context, 01170 XalanNode::NodeType nodeType) const; 01171 01172 eMatchScore 01173 testElementTotallyWild( 01174 const XalanNode& context, 01175 XalanNode::NodeType nodeType) const; 01176 01177 eMatchScore 01178 testElementNCName2(const XalanElement& context) const; 01179 01180 eMatchScore 01181 testElementQName2(const XalanElement& context) const; 01182 01183 eMatchScore 01184 testElementNamespaceOnly2(const XalanElement& context) const; 01185 01186 eMatchScore 01187 testElementTotallyWild2(const XalanElement& context) const; 01188 01189 eMatchScore 01190 testNamespaceNCName( 01191 const XalanNode& context, 01192 XalanNode::NodeType nodeType) const; 01193 01194 eMatchScore 01195 testNamespaceTotallyWild( 01196 const XalanNode& context, 01197 XalanNode::NodeType nodeType) const; 01198 01199 eMatchScore 01200 testDefault( 01201 const XalanNode& context, 01202 XalanNode::NodeType nodeType) const; 01203 01204 eMatchScore 01205 testDefault2(const XalanElement& context) const; 01206 01207 bool 01208 matchLocalName(const XalanNode& context) const; 01209 01210 bool 01211 matchNamespaceURI(const XalanNode& context) const; 01212 01213 bool 01214 matchLocalNameAndNamespaceURI(const XalanNode& context) const; 01215 01216 bool 01217 matchNamespace(const XalanNode& context) const; 01218 01219 bool 01220 shouldStripSourceNode(const XalanText& context) const; 01221 01222 // Data members... 01223 XPathExecutionContext* m_executionContext; 01224 01225 const XalanDOMString* m_targetNamespace; 01226 01227 const XalanDOMString* m_targetLocalName; 01228 01229 TestFunctionPtr m_testFunction; 01230 01231 TestFunctionPtr2 m_testFunction2; 01232 }; 01233 01234 friend class NodeTester; 01235 01236 protected: 01237 01246 const XObjectPtr 01247 locationPath( 01248 XalanNode* context, 01249 OpCodeMapPositionType opPos, 01250 XPathExecutionContext& executionContext) const; 01251 01260 void 01261 locationPath( 01262 XalanNode* context, 01263 OpCodeMapPositionType opPos, 01264 XPathExecutionContext& executionContext, 01265 bool& theResult) const; 01266 01275 void 01276 locationPath( 01277 XalanNode* context, 01278 OpCodeMapPositionType opPos, 01279 XPathExecutionContext& executionContext, 01280 double& theResult) const; 01281 01290 void 01291 locationPath( 01292 XalanNode* context, 01293 OpCodeMapPositionType opPos, 01294 XPathExecutionContext& executionContext, 01295 XalanDOMString& theResult) const; 01296 01306 void 01307 locationPath( 01308 XalanNode* context, 01309 OpCodeMapPositionType opPos, 01310 XPathExecutionContext& executionContext, 01311 FormatterListener& formatterListener, 01312 MemberFunctionPtr function) const; 01313 01322 void 01323 locationPath( 01324 XalanNode* context, 01325 OpCodeMapPositionType opPos, 01326 XPathExecutionContext& executionContext, 01327 MutableNodeRefList& theResult) const 01328 { 01329 step(executionContext, context, opPos + 2, theResult); 01330 } 01331 01340 const XObjectPtr 01341 executeMore( 01342 XalanNode* context, 01343 OpCodeMapPositionType opPos, 01344 XPathExecutionContext& executionContext) const; 01345 01354 void 01355 executeMore( 01356 XalanNode* context, 01357 OpCodeMapPositionType opPos, 01358 XPathExecutionContext& executionContext, 01359 bool& theResult) const; 01360 01369 void 01370 executeMore( 01371 XalanNode* context, 01372 OpCodeMapPositionType opPos, 01373 XPathExecutionContext& executionContext, 01374 double& theResult) const; 01375 01385 void 01386 executeMore( 01387 XalanNode* context, 01388 OpCodeMapPositionType opPos, 01389 XPathExecutionContext& executionContext, 01390 XalanDOMString& theResult) const; 01391 01401 void 01402 executeMore( 01403 XalanNode* context, 01404 OpCodeMapPositionType opPos, 01405 XPathExecutionContext& executionContext, 01406 FormatterListener& formatterListener, 01407 MemberFunctionPtr function) const; 01408 01418 const XObjectPtr 01419 executeMore( 01420 XalanNode* context, 01421 OpCodeMapPositionType opPos, 01422 XPathExecutionContext& executionContext, 01423 MutableNodeRefList& theResult) const; 01424 01431 void 01432 doGetMatchScore( 01433 XalanNode* context, 01434 XPathExecutionContext& executionContext, 01435 eMatchScore& score) const; 01436 01444 bool 01445 Or( 01446 XalanNode* context, 01447 OpCodeMapPositionType opPos, 01448 XPathExecutionContext& executionContext) const; 01449 01457 bool 01458 And( 01459 XalanNode* context, 01460 OpCodeMapPositionType opPos, 01461 XPathExecutionContext& executionContext) const; 01462 01470 bool 01471 notequals( 01472 XalanNode* context, 01473 OpCodeMapPositionType opPos, 01474 XPathExecutionContext& executionContext) const; 01475 01483 bool 01484 equals( 01485 XalanNode* context, 01486 OpCodeMapPositionType opPos, 01487 XPathExecutionContext& executionContext) const; 01488 01496 bool 01497 lte( 01498 XalanNode* context, 01499 OpCodeMapPositionType opPos, 01500 XPathExecutionContext& executionContext) const; 01501 01509 bool 01510 lt( 01511 XalanNode* context, 01512 OpCodeMapPositionType opPos, 01513 XPathExecutionContext& executionContext) const; 01514 01522 bool 01523 gte( 01524 XalanNode* context, 01525 OpCodeMapPositionType opPos, 01526 XPathExecutionContext& executionContext) const; 01527 01535 bool 01536 gt( 01537 XalanNode* context, 01538 OpCodeMapPositionType opPos, 01539 XPathExecutionContext& executionContext) const; 01540 01548 double 01549 plus( 01550 XalanNode* context, 01551 OpCodeMapPositionType opPos, 01552 XPathExecutionContext& executionContext) const; 01553 01562 void 01563 plus( 01564 XalanNode* context, 01565 OpCodeMapPositionType opPos, 01566 XPathExecutionContext& executionContext, 01567 FormatterListener& formatterListener, 01568 MemberFunctionPtr function) const; 01569 01577 double 01578 minus( 01579 XalanNode* context, 01580 OpCodeMapPositionType opPos, 01581 XPathExecutionContext& executionContext) const; 01582 01591 void 01592 minus( 01593 XalanNode* context, 01594 OpCodeMapPositionType opPos, 01595 XPathExecutionContext& executionContext, 01596 FormatterListener& formatterListener, 01597 MemberFunctionPtr function) const; 01598 01606 double 01607 mult( 01608 XalanNode* context, 01609 OpCodeMapPositionType opPos, 01610 XPathExecutionContext& executionContext) const; 01611 01620 void 01621 mult( 01622 XalanNode* context, 01623 OpCodeMapPositionType opPos, 01624 XPathExecutionContext& executionContext, 01625 FormatterListener& formatterListener, 01626 MemberFunctionPtr function) const; 01627 01635 double 01636 div( 01637 XalanNode* context, 01638 OpCodeMapPositionType opPos, 01639 XPathExecutionContext& executionContext) const; 01640 01649 void 01650 div( 01651 XalanNode* context, 01652 OpCodeMapPositionType opPos, 01653 XPathExecutionContext& executionContext, 01654 FormatterListener& formatterListener, 01655 MemberFunctionPtr function) const; 01656 01664 double 01665 mod( 01666 XalanNode* context, 01667 OpCodeMapPositionType opPos, 01668 XPathExecutionContext& executionContext) const; 01669 01678 void 01679 mod( 01680 XalanNode* context, 01681 OpCodeMapPositionType opPos, 01682 XPathExecutionContext& executionContext, 01683 FormatterListener& formatterListener, 01684 MemberFunctionPtr function) const; 01685 01693 double 01694 neg( 01695 XalanNode* context, 01696 OpCodeMapPositionType opPos, 01697 XPathExecutionContext& executionContext) const; 01698 01707 void 01708 neg( 01709 XalanNode* context, 01710 OpCodeMapPositionType opPos, 01711 XPathExecutionContext& executionContext, 01712 FormatterListener& formatterListener, 01713 MemberFunctionPtr function) const; 01714 01722 const XObjectPtr 01723 Union( 01724 XalanNode* context, 01725 OpCodeMapPositionType opPos, 01726 XPathExecutionContext& executionContext) const; 01727 01736 void 01737 Union( 01738 XalanNode* context, 01739 OpCodeMapPositionType opPos, 01740 XPathExecutionContext& executionContext, 01741 bool& result) const; 01742 01751 void 01752 Union( 01753 XalanNode* context, 01754 OpCodeMapPositionType opPos, 01755 XPathExecutionContext& executionContext, 01756 double& result) const; 01757 01766 void 01767 Union( 01768 XalanNode* context, 01769 OpCodeMapPositionType opPos, 01770 XPathExecutionContext& executionContext, 01771 XalanDOMString& result) const; 01772 01782 void 01783 Union( 01784 XalanNode* context, 01785 OpCodeMapPositionType opPos, 01786 XPathExecutionContext& executionContext, 01787 FormatterListener& formatterListener, 01788 MemberFunctionPtr function) const; 01789 01797 void 01798 Union( 01799 XalanNode* context, 01800 OpCodeMapPositionType opPos, 01801 XPathExecutionContext& executionContext, 01802 MutableNodeRefList& result) const; 01803 01810 const XObjectPtr 01811 literal( 01812 OpCodeMapPositionType opPos, 01813 XPathExecutionContext& executionContext) const; 01814 01821 void 01822 literal( 01823 OpCodeMapPositionType opPos, 01824 bool& theResult) const; 01825 01832 void 01833 literal( 01834 OpCodeMapPositionType opPos, 01835 double& theResult) const; 01836 01844 void 01845 literal( 01846 OpCodeMapPositionType opPos, 01847 XalanDOMString& theResult) const; 01848 01855 void 01856 literal( 01857 OpCodeMapPositionType opPos, 01858 FormatterListener& formatterListener, 01859 MemberFunctionPtr function) const; 01860 01867 const XObjectPtr 01868 variable( 01869 OpCodeMapPositionType opPos, 01870 XPathExecutionContext& executionContext) const; 01871 01879 const XObjectPtr 01880 group( 01881 XalanNode* context, 01882 OpCodeMapPositionType opPos, 01883 XPathExecutionContext& executionContext) const 01884 { 01885 return executeMore(context, opPos + 2, executionContext); 01886 } 01887 01895 void 01896 group( 01897 XalanNode* context, 01898 OpCodeMapPositionType opPos, 01899 XPathExecutionContext& executionContext, 01900 bool& theResult) const 01901 { 01902 executeMore(context, opPos + 2, executionContext, theResult); 01903 } 01904 01912 void 01913 group( 01914 XalanNode* context, 01915 OpCodeMapPositionType opPos, 01916 XPathExecutionContext& executionContext, 01917 double& theResult) const 01918 { 01919 executeMore(context, opPos + 2, executionContext, theResult); 01920 } 01921 01929 void 01930 group( 01931 XalanNode* context, 01932 OpCodeMapPositionType opPos, 01933 XPathExecutionContext& executionContext, 01934 XalanDOMString& theResult) const 01935 { 01936 executeMore(context, opPos + 2, executionContext, theResult); 01937 } 01938 01948 void 01949 group( 01950 XalanNode* context, 01951 OpCodeMapPositionType opPos, 01952 XPathExecutionContext& executionContext, 01953 FormatterListener& formatterListener, 01954 MemberFunctionPtr function) const 01955 { 01956 executeMore(context, opPos + 2, executionContext, formatterListener, function); 01957 } 01958 01966 void 01967 group( 01968 XalanNode* context, 01969 OpCodeMapPositionType opPos, 01970 XPathExecutionContext& executionContext, 01971 MutableNodeRefList& theResult) const 01972 { 01973 executeMore(context, opPos + 2, executionContext, theResult); 01974 } 01975 01981 double 01982 numberlit(OpCodeMapPositionType opPos) const; 01983 01989 const XObjectPtr 01990 numberlit( 01991 OpCodeMapPositionType opPos, 01992 XPathExecutionContext& executionContext) const; 01993 02000 void 02001 numberlit( 02002 OpCodeMapPositionType opPos, 02003 bool& theResult) const; 02004 02012 void 02013 numberlit( 02014 OpCodeMapPositionType opPos, 02015 XalanDOMString& theResult) const; 02016 02024 void 02025 numberlit( 02026 OpCodeMapPositionType opPos, 02027 FormatterListener& formatterListener, 02028 MemberFunctionPtr function) const; 02029 02037 const XObjectPtr 02038 runExtFunction( 02039 XalanNode* context, 02040 OpCodeMapPositionType opPos, 02041 XPathExecutionContext& executionContext) const; 02042 02052 const XObjectPtr 02053 extfunction( 02054 XalanNode* context, 02055 OpCodeMapPositionType /* opPos */, 02056 const XalanDOMString& theNamespace, 02057 const XalanDOMString& functionName, 02058 const Function::XObjectArgVectorType& argVec, 02059 XPathExecutionContext& executionContext) const 02060 { 02061 return executionContext.extFunction(theNamespace, 02062 functionName, 02063 context, 02064 argVec, 02065 m_locator); 02066 } 02067 02075 const XObjectPtr 02076 runFunction( 02077 XalanNode* context, 02078 OpCodeMapPositionType opPos, 02079 XPathExecutionContext& executionContext) const; 02080 02089 const XObjectPtr 02090 function( 02091 XalanNode* context, 02092 OpCodeMapValueType funcID, 02093 const Function::XObjectArgVectorType& argVec, 02094 XPathExecutionContext& executionContext) const 02095 { 02096 return s_functions[funcID].execute(executionContext, context, argVec, m_locator); 02097 } 02098 02106 double 02107 functionPosition( 02108 XalanNode* context, 02109 XPathExecutionContext& executionContext) const 02110 { 02111 assert(context != 0); 02112 02113 return executionContext.getContextNodeListPosition(*context); 02114 } 02115 02122 double 02123 functionLast(XPathExecutionContext& executionContext) const 02124 { 02125 return executionContext.getContextNodeListLength(); 02126 } 02127 02136 double 02137 functionCount( 02138 XalanNode* context, 02139 OpCodeMapPositionType opPos, 02140 XPathExecutionContext& executionContext) const; 02141 02150 bool 02151 functionNot( 02152 XalanNode* context, 02153 OpCodeMapPositionType opPos, 02154 XPathExecutionContext& executionContext) const 02155 { 02156 assert(context != 0); 02157 02158 return !functionBoolean(context, opPos, executionContext); 02159 } 02160 02169 bool 02170 functionBoolean( 02171 XalanNode* context, 02172 OpCodeMapPositionType opPos, 02173 XPathExecutionContext& executionContext) const 02174 { 02175 assert(context != 0); 02176 02177 bool result; 02178 02179 executeMore(context, opPos + 2, executionContext, result); 02180 02181 return result; 02182 } 02183 02190 const XalanDOMString& 02191 functionName(XalanNode* context) const 02192 { 02193 assert(context != 0); 02194 02195 return DOMServices::getNameOfNode(*context); 02196 } 02197 02206 const XalanDOMString& 02207 functionName( 02208 XalanNode* context, 02209 OpCodeMapPositionType opPos, 02210 XPathExecutionContext& executionContext) const; 02211 02218 const XalanDOMString& 02219 functionLocalName(XalanNode* context) const; 02220 02229 const XalanDOMString& 02230 functionLocalName( 02231 XalanNode* context, 02232 OpCodeMapPositionType opPos, 02233 XPathExecutionContext& executionContext) const; 02234 02242 double 02243 functionNumber( 02244 XalanNode* context, 02245 XPathExecutionContext& executionContext) const 02246 { 02247 assert(context != 0); 02248 02249 return XObject::number(executionContext, *context); 02250 } 02251 02260 double 02261 functionNumber( 02262 XalanNode* context, 02263 OpCodeMapPositionType opPos, 02264 XPathExecutionContext& executionContext) const 02265 { 02266 double result; 02267 02268 executeMore(context, opPos + 2, executionContext, result); 02269 02270 return result; 02271 } 02272 02281 double 02282 functionFloor( 02283 XalanNode* context, 02284 OpCodeMapPositionType opPos, 02285 XPathExecutionContext& executionContext) const 02286 { 02287 return DoubleSupport::floor(functionNumber(context, opPos, executionContext)); 02288 } 02289 02298 double 02299 functionCeiling( 02300 XalanNode* context, 02301 OpCodeMapPositionType opPos, 02302 XPathExecutionContext& executionContext) const 02303 { 02304 return DoubleSupport::ceiling(functionNumber(context, opPos, executionContext)); 02305 } 02306 02315 double 02316 functionRound( 02317 XalanNode* context, 02318 OpCodeMapPositionType opPos, 02319 XPathExecutionContext& executionContext) const 02320 { 02321 return DoubleSupport::round(functionNumber(context, opPos, executionContext)); 02322 } 02323 02330 double 02331 functionStringLength(XalanNode* context) const; 02332 02341 double 02342 functionStringLength( 02343 XalanNode* context, 02344 OpCodeMapPositionType opPos, 02345 XPathExecutionContext& executionContext) const; 02346 02355 double 02356 functionSum( 02357 XalanNode* context, 02358 OpCodeMapPositionType opPos, 02359 XPathExecutionContext& executionContext) const; 02360 02368 double 02369 getNumericOperand( 02370 XalanNode* context, 02371 OpCodeMapPositionType opPos, 02372 XPathExecutionContext& executionContext) const; 02373 02374 private: 02375 02376 // These are not implemented... 02377 XPath(const XPath&); 02378 02379 XPath& 02380 operator=(const XPath&); 02381 02382 bool 02383 operator==(const XPath&) const; 02384 02385 // Default vector allocation sizes. 02386 enum 02387 { 02388 eDefaultTargetDataSize = 5 02389 }; 02390 02391 eMatchScore 02392 locationPathPattern( 02393 XPathExecutionContext& executionContext, 02394 XalanNode& context, 02395 OpCodeMapPositionType opPos) const; 02396 02397 protected: 02398 02399 void 02400 step( 02401 XPathExecutionContext& executionContext, 02402 XalanNode* context, 02403 OpCodeMapPositionType opPos, 02404 MutableNodeRefList& queryResults) const; 02405 02416 XalanNode* 02417 stepPattern( 02418 XPathExecutionContext& executionContext, 02419 XalanNode* context, 02420 OpCodeMapPositionType opPos, 02421 eMatchScore& scoreHolder) const; 02422 02423 OpCodeMapPositionType 02424 findNodeSet( 02425 XPathExecutionContext& executionContext, 02426 XalanNode* context, 02427 OpCodeMapPositionType opPos, 02428 OpCodeMapValueType stepType, 02429 MutableNodeRefList& subQueryResults) const; 02430 02431 OpCodeMapPositionType 02432 findRoot( 02433 XPathExecutionContext& executionContext, 02434 XalanNode* context, 02435 OpCodeMapPositionType opPos, 02436 OpCodeMapValueType stepType, 02437 MutableNodeRefList& subQueryResults) const; 02438 02439 OpCodeMapPositionType 02440 findParent( 02441 XPathExecutionContext& executionContext, 02442 XalanNode* context, 02443 OpCodeMapPositionType opPos, 02444 OpCodeMapValueType stepType, 02445 MutableNodeRefList& subQueryResults) const; 02446 02447 OpCodeMapPositionType 02448 findSelf( 02449 XPathExecutionContext& executionContext, 02450 XalanNode* context, 02451 OpCodeMapPositionType opPos, 02452 OpCodeMapValueType stepType, 02453 MutableNodeRefList& subQueryResults) const; 02454 02455 OpCodeMapPositionType 02456 findAncestors( 02457 XPathExecutionContext& executionContext, 02458 XalanNode* context, 02459 OpCodeMapPositionType opPos, 02460 OpCodeMapValueType stepType, 02461 MutableNodeRefList& subQueryResults) const; 02462 02463 OpCodeMapPositionType 02464 findAncestorsOrSelf( 02465 XPathExecutionContext& executionContext, 02466 XalanNode* context, 02467 OpCodeMapPositionType opPos, 02468 OpCodeMapValueType stepType, 02469 MutableNodeRefList& subQueryResults) const; 02470 02471 OpCodeMapPositionType 02472 findAttributes( 02473 XPathExecutionContext& executionContext, 02474 XalanNode* context, 02475 OpCodeMapPositionType opPos, 02476 OpCodeMapValueType stepType, 02477 MutableNodeRefList& subQueryResults) const; 02478 02479 OpCodeMapPositionType 02480 findChildren( 02481 XPathExecutionContext& executionContext, 02482 XalanNode* context, 02483 OpCodeMapPositionType opPos, 02484 OpCodeMapValueType stepType, 02485 MutableNodeRefList& subQueryResults) const; 02486 02487 OpCodeMapPositionType 02488 findDescendants( 02489 XPathExecutionContext& executionContext, 02490 XalanNode* context, 02491 OpCodeMapPositionType opPos, 02492 OpCodeMapValueType stepType, 02493 MutableNodeRefList& subQueryResults) const; 02494 02495 OpCodeMapPositionType 02496 findFollowing( 02497 XPathExecutionContext& executionContext, 02498 XalanNode* context, 02499 OpCodeMapPositionType opPos, 02500 OpCodeMapValueType stepType, 02501 MutableNodeRefList& subQueryResults) const; 02502 02503 OpCodeMapPositionType 02504 findFollowingSiblings( 02505 XPathExecutionContext& executionContext, 02506 XalanNode* context, 02507 OpCodeMapPositionType opPos, 02508 OpCodeMapValueType stepType, 02509 MutableNodeRefList& subQueryResults) const; 02510 02511 OpCodeMapPositionType 02512 findPreceeding( 02513 XPathExecutionContext& executionContext, 02514 XalanNode* context, 02515 OpCodeMapPositionType opPos, 02516 OpCodeMapValueType stepType, 02517 MutableNodeRefList& subQueryResults) const; 02518 02519 OpCodeMapPositionType 02520 findPreceedingSiblings( 02521 XPathExecutionContext& executionContext, 02522 XalanNode* context, 02523 OpCodeMapPositionType opPos, 02524 OpCodeMapValueType stepType, 02525 MutableNodeRefList& subQueryResults) const; 02526 02527 OpCodeMapPositionType 02528 findNamespace( 02529 XPathExecutionContext& executionContext, 02530 XalanNode* context, 02531 OpCodeMapPositionType opPos, 02532 OpCodeMapValueType stepType, 02533 MutableNodeRefList& subQueryResults) const; 02534 02535 OpCodeMapPositionType 02536 findNodesOnUnknownAxis( 02537 XPathExecutionContext& executionContext, 02538 XalanNode* context, 02539 OpCodeMapPositionType opPos, 02540 OpCodeMapValueType stepType, 02541 MutableNodeRefList& subQueryResults) const; 02542 02543 #if !defined(NDEBUG) 02544 eMatchScore 02545 nodeTest( 02546 XPathExecutionContext& executionContext, 02547 XalanNode* context, 02548 XalanNode::NodeType nodeType, 02549 OpCodeMapPositionType opPos, 02550 OpCodeMapValueType argLen, 02551 OpCodeMapValueType stepType) const; 02552 #endif 02553 02554 OpCodeMapPositionType 02555 predicates( 02556 XPathExecutionContext& executionContext, 02557 OpCodeMapPositionType opPos, 02558 MutableNodeRefList& subQueryResults) const; 02559 02560 eMatchScore 02561 handleFoundIndex( 02562 XPathExecutionContext& executionContext, 02563 XalanNode* localContext, 02564 OpCodeMapPositionType startOpPos) const; 02565 02566 eMatchScore 02567 handleFoundIndexPositional( 02568 XPathExecutionContext& executionContext, 02569 XalanNode* localContext, 02570 OpCodeMapPositionType startOpPos) const; 02571 02572 private: 02573 02574 void 02575 unknownOpCodeError( 02576 XalanNode* context, 02577 XPathExecutionContext& executionContext, 02578 OpCodeMapPositionType opPos) const; 02579 02580 void 02581 notNodeSetError( 02582 XalanNode* context, 02583 XPathExecutionContext& executionContext) const; 02584 02585 // Data members... 02586 02592 XPathExpression m_expression; 02593 02597 const LocatorType* m_locator; 02598 02604 bool m_inStylesheet; 02605 02611 static FunctionTableType s_functions; 02612 02613 static const XalanDOMString s_emptyString; 02614 }; 02615 02616 02617 02618 XALAN_CPP_NAMESPACE_END 02619 02620 02621 02622 #endif // XPATH_HEADER_GUARD_1357924680

Interpreting class diagrams

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

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