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(XPATHPROCESSORIMPL_HEADER_GUARD_1357924680) 00017 #define XPATHPROCESSORIMPL_HEADER_GUARD_1357924680 00018 00019 00020 00021 // Base header file. Must be first. 00022 #include <xalanc/XPath/XPathDefinitions.hpp> 00023 00024 00025 00026 #include <cstdlib> 00027 00028 00029 00030 #include <xalanc/XalanDOM/XalanDOMString.hpp> 00031 00032 00033 00034 #include <xalanc/Include/XalanVector.hpp> 00035 #include <xalanc/Include/XalanMap.hpp> 00036 00037 00038 00039 // Base class header file... 00040 #include <xalanc/XPath/XPathProcessor.hpp> 00041 00042 00043 00044 #include <xalanc/XPath/XPath.hpp> 00045 00046 00047 00048 XALAN_CPP_NAMESPACE_BEGIN 00049 00050 00051 00052 class XalanNode; 00053 00054 00055 00060 class XALAN_XPATH_EXPORT XPathProcessorImpl : public XPathProcessor 00061 { 00062 public: 00063 00064 typedef XalanMap<XalanDOMString, 00065 const XalanDOMString*> StringToStringMapType; 00066 00067 typedef XalanVector<bool> BoolVectorType; 00068 00069 XPathProcessorImpl(MemoryManagerType& theManager XALAN_DEFAULT_MEMMGR); 00070 00071 virtual 00072 ~XPathProcessorImpl(); 00073 00074 00075 static XPathProcessorImpl* 00076 create(MemoryManagerType& theManager); 00077 // These are inherited from XPathProcessor... 00078 00079 virtual void 00080 initXPath( 00081 XPath& pathObj, 00082 XPathConstructionContext& constructionContext, 00083 const XalanDOMString& expression, 00084 const PrefixResolver& resolver, 00085 const LocatorType* locator = 0); 00086 00087 virtual void 00088 initMatchPattern( 00089 XPath& pathObj, 00090 XPathConstructionContext& constructionContext, 00091 const XalanDOMString& expression, 00092 const PrefixResolver& resolver, 00093 const LocatorType* locator = 0); 00094 00095 private: 00096 00103 void 00104 tokenize(const XalanDOMString& pat); 00105 00106 void 00107 addToTokenQueue(const XalanDOMString& s) const; 00108 00109 void 00110 replaceTokenWithNamespaceToken() const; 00111 00116 int 00117 mapNSTokens( 00118 const XalanDOMString& pat, 00119 int startSubstring, 00120 int posOfNSSep, 00121 int posOfScan); 00122 00128 bool 00129 tokenIs(const XalanDOMString& s) const; 00130 00136 bool 00137 tokenIs(const XalanDOMChar* s) const; 00138 00144 bool 00145 tokenIs(XalanDOMChar c) const; 00146 00154 bool 00155 lookahead( 00156 XalanDOMChar c, 00157 int n) const; 00158 00166 bool 00167 lookahead( 00168 const XalanDOMChar* s, 00169 int n) const; 00170 00178 bool 00179 lookahead( 00180 const XalanDOMString& s, 00181 int n) const; 00182 00193 bool 00194 lookbehind( 00195 char c, 00196 int n) const; 00197 00208 bool 00209 lookbehindHasToken(int n) const; 00210 00215 bool 00216 nextToken(); 00217 00222 const XalanDOMString& 00223 getTokenRelative(int theOffset) const; 00224 00229 void 00230 prevToken(); 00231 00236 void 00237 consumeExpected(XalanDOMChar expected); 00238 00239 bool 00240 isCurrentLiteral() const; 00241 00248 static bool 00249 isAxis(const XalanDOMString& theToken); 00250 00257 static bool 00258 isNodeTest(const XalanDOMString& theToken); 00259 00263 void 00264 error(const XalanDOMString& msg) const; 00265 00269 static XPathExpression::eOpCodes 00270 getFunctionToken(const XalanDOMString& key) 00271 { 00272 return searchTable(s_functionTable, s_functionTableSize, key).m_opCode; 00273 } 00274 00278 static XPathExpression::eOpCodes 00279 getNodeTypeToken(const XalanDOMString& key) 00280 { 00281 return searchTable(s_nodeTypeTable, s_nodeTypeTableSize, key).m_opCode; 00282 } 00283 00287 static XPathExpression::eOpCodes 00288 getAxisToken(const XalanDOMString& key) 00289 { 00290 return searchTable(s_axisTable, s_axisTableSize, key).m_opCode; 00291 } 00292 00299 void 00300 Expr(); 00301 00302 00310 void 00311 OrExpr(); 00312 00320 void 00321 AndExpr() ; 00322 00332 int 00333 EqualityExpr(int opCodePos = -1); 00334 00347 int 00348 RelationalExpr(int opCodePos = -1); 00349 00360 int 00361 AdditiveExpr(int opCodePos = -1); 00362 00375 int 00376 MultiplicativeExpr(int opCodePos = -1); 00377 00387 void 00388 UnaryExpr(); 00389 00401 void 00402 UnionExpr(); 00403 00415 void 00416 PathExpr(); 00417 00427 void 00428 FilterExpr(); 00429 00439 void 00440 PrimaryExpr(); 00441 00442 00448 void 00449 Argument(); 00450 00456 void 00457 FunctionCall(); 00458 00459 void 00460 FunctionPosition(); 00461 00462 void 00463 FunctionLast(); 00464 00465 void 00466 FunctionCount(); 00467 00468 void 00469 FunctionNot(); 00470 00471 void 00472 FunctionTrue(); 00473 00474 void 00475 FunctionFalse(); 00476 00477 void 00478 FunctionBoolean(); 00479 00480 void 00481 FunctionName(int opPos); 00482 00483 void 00484 FunctionLocalName(int opPos); 00485 00486 void 00487 FunctionNumber(int opPos); 00488 00489 void 00490 FunctionFloor(); 00491 00492 void 00493 FunctionCeiling(); 00494 00495 void 00496 FunctionRound(); 00497 00498 void 00499 FunctionString(int opPos); 00500 00501 void 00502 FunctionStringLength(int opPos); 00503 00504 void 00505 FunctionSum(); 00506 00507 void 00508 FunctionNamespaceURI(int opPos); 00509 00516 void 00517 LocationPath(); 00518 00526 void 00527 RelativeLocationPath(); 00528 00534 void 00535 Step(); 00536 00542 void 00543 Basis(); 00544 00550 XPathExpression::eOpCodes 00551 AxisName(); 00552 00559 int 00560 NodeTest(); 00561 00567 void 00568 Predicate(); 00569 00575 void 00576 PredicateExpr(); 00577 00583 void 00584 QName(); 00585 00590 void 00591 NCName(); 00592 00601 void 00602 Literal(); 00603 00609 void 00610 Number(); 00611 00618 void 00619 Pattern(); 00620 00629 void 00630 LocationPathPattern(); 00631 00639 void 00640 IdKeyPattern(); 00641 00649 void 00650 RelativePathPattern(); 00651 00657 void 00658 StepPattern(); 00659 00665 void 00666 AbbreviatedNodeTestStep(); 00667 00668 static bool 00669 isValidFunction(const XalanDOMString& key); 00670 00671 private: 00672 00673 int 00674 FunctionCallArguments(); 00675 00676 struct TableEntry 00677 { 00678 const XalanDOMChar* m_string; 00679 00680 XPathExpression::eOpCodes m_opCode; 00681 }; 00682 00683 #if defined(XALAN_STRICT_ANSI_HEADERS) 00684 typedef std::size_t size_type; 00685 #else 00686 typedef size_t size_type; 00687 #endif 00688 00689 static const TableEntry& 00690 searchTable( 00691 const TableEntry theTable[], 00692 size_type theTableSize, 00693 const XalanDOMString& theString); 00694 00698 XalanDOMString m_token; 00699 00705 XalanDOMChar m_tokenChar; 00706 00710 XPath* m_xpath; 00711 00715 XPathConstructionContext* m_constructionContext; 00716 00720 XPathExpression* m_expression; 00721 00725 const PrefixResolver* m_prefixResolver; 00726 00727 bool m_requireLiterals; 00728 00729 bool m_isMatchPattern; 00730 00731 const LocatorType* m_locator; 00732 00733 BoolVectorType m_positionPredicateStack; 00734 00735 StringToStringMapType m_namespaces; 00736 00737 00738 // Static stuff here... 00739 static const XalanDOMString s_emptyString; 00740 00741 static const XalanDOMChar s_functionIDString[]; 00742 00743 // This shouldn't really be here, since it's not part of the XPath standard, 00744 // but rather a part ofthe XSLT standard. 00745 static const XalanDOMChar s_functionKeyString[]; 00746 00747 static const XalanDOMChar s_orString[]; 00748 00749 static const XalanDOMChar s_andString[]; 00750 00751 static const XalanDOMChar s_divString[]; 00752 00753 static const XalanDOMChar s_modString[]; 00754 00755 static const XalanDOMChar s_dotString[]; 00756 00757 static const XalanDOMChar s_dotDotString[]; 00758 00759 static const XalanDOMChar s_axisString[]; 00760 00761 static const XalanDOMChar s_attributeString[]; 00762 00763 static const XalanDOMChar s_childString[]; 00764 00765 static const XalanDOMChar s_lastString[]; 00766 00767 static const XalanDOMChar s_positionString[]; 00768 00769 static const XalanDOMChar s_asteriskString[]; 00770 00771 static const XalanDOMChar s_commentString[]; 00772 00773 static const XalanDOMChar s_piString[]; 00774 00775 static const XalanDOMChar s_nodeString[]; 00776 00777 static const XalanDOMChar s_textString[]; 00778 00779 static const XalanDOMChar s_ancestorString[]; 00780 00781 static const XalanDOMChar s_ancestorOrSelfString[]; 00782 00783 static const XalanDOMChar s_descendantString[]; 00784 00785 static const XalanDOMChar s_descendantOrSelfString[]; 00786 00787 static const XalanDOMChar s_followingString[]; 00788 00789 static const XalanDOMChar s_followingSiblingString[]; 00790 00791 static const XalanDOMChar s_parentString[]; 00792 00793 static const XalanDOMChar s_precedingString[]; 00794 00795 static const XalanDOMChar s_precedingSiblingString[]; 00796 00797 static const XalanDOMChar s_selfString[]; 00798 00799 static const XalanDOMChar s_namespaceString[]; 00800 00801 static const TableEntry s_functionTable[]; 00802 00803 static const size_type s_functionTableSize; 00804 00805 static const TableEntry s_nodeTypeTable[]; 00806 00807 static const size_type s_nodeTypeTableSize; 00808 00809 static const TableEntry s_axisTable[]; 00810 00811 static const size_type s_axisTableSize; 00812 00813 static const TableEntry s_dummyEntry; 00814 }; 00815 00816 00817 00818 XALAN_CPP_NAMESPACE_END 00819 00820 00821 00822 #endif // XPATHPROCESSORIMPL_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.9 |
|