00001 /* 00002 * The Apache Software License, Version 1.1 00003 * 00004 * 00005 * Copyright (c) 1999 The Apache Software Foundation. All rights 00006 * reserved. 00007 * 00008 * Redistribution and use in source and binary forms, with or without 00009 * modification, are permitted provided that the following conditions 00010 * are met: 00011 * 00012 * 1. Redistributions of source code must retain the above copyright 00013 * notice, this list of conditions and the following disclaimer. 00014 * 00015 * 2. Redistributions in binary form must reproduce the above copyright 00016 * notice, this list of conditions and the following disclaimer in 00017 * the documentation and/or other materials provided with the 00018 * distribution. 00019 * 00020 * 3. The end-user documentation included with the redistribution, 00021 * if any, must include the following acknowledgment: 00022 * "This product includes software developed by the 00023 * Apache Software Foundation (http://www.apache.org/)." 00024 * Alternately, this acknowledgment may appear in the software itself, 00025 * if and wherever such third-party acknowledgments normally appear. 00026 * 00027 * 4. The names "Xalan" and "Apache Software Foundation" must 00028 * not be used to endorse or promote products derived from this 00029 * software without prior written permission. For written 00030 * permission, please contact apache@apache.org. 00031 * 00032 * 5. Products derived from this software may not be called "Apache", 00033 * nor may "Apache" appear in their name, without prior written 00034 * permission of the Apache Software Foundation. 00035 * 00036 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 00037 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00038 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00039 * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR 00040 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00041 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00042 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 00043 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 00044 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00045 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 00046 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 00047 * SUCH DAMAGE. 00048 * ==================================================================== 00049 * 00050 * This software consists of voluntary contributions made by many 00051 * individuals on behalf of the Apache Software Foundation and was 00052 * originally based on software copyright (c) 1999, International 00053 * Business Machines, Inc., http://www.ibm.com. For more 00054 * information on the Apache Software Foundation, please see 00055 * <http://www.apache.org/>. 00056 */ 00057 #if !defined(XPATHPROCESSORIMPL_HEADER_GUARD_1357924680) 00058 #define XPATHPROCESSORIMPL_HEADER_GUARD_1357924680 00059 00060 00061 00062 // Base header file. Must be first. 00063 #include <XPath/XPathDefinitions.hpp> 00064 00065 00066 00067 #include <set> 00068 #include <vector> 00069 00070 00071 00072 #include <XalanDOM/XalanDOMString.hpp> 00073 00074 00075 00076 // Base class header file... 00077 #include <XPath/XPathProcessor.hpp> 00078 00079 00080 00081 #include <XPath/XPath.hpp> 00082 00083 00084 00085 class XalanNode; 00086 00087 00088 00093 class XALAN_XPATH_EXPORT XPathProcessorImpl : public XPathProcessor 00094 { 00095 public: 00096 00097 #if defined(XALAN_NO_NAMESPACES) 00098 typedef map<XalanDOMString, 00099 int, 00100 less<XalanDOMString> > KeywordsMapType; 00101 typedef map<XalanDOMString, 00102 XPathExpression::eOpCodes, 00103 less<XalanDOMString> > FunctionNameMapType; 00104 typedef map<XalanDOMString, 00105 XPathExpression::eOpCodes, 00106 less<XalanDOMString> > AxisNamesMapType; 00107 typedef map<XalanDOMString, 00108 XPathExpression::eOpCodes, 00109 less<XalanDOMString> > NodeTypesMapType; 00110 00111 typedef vector<XalanDOMString> DOMStringVectorType; 00112 #else 00113 typedef std::map<XalanDOMString, 00114 int> KeywordsMapType; 00115 typedef std::map<XalanDOMString, 00116 XPathExpression::eOpCodes> FunctionNameMapType; 00117 typedef std::map<XalanDOMString, 00118 XPathExpression::eOpCodes> AxisNamesMapType; 00119 typedef std::map<XalanDOMString, 00120 XPathExpression::eOpCodes> NodeTypesMapType; 00121 00122 typedef std::vector<XalanDOMString> DOMStringVectorType; 00123 #endif 00124 00128 static void 00129 initialize(); 00130 00134 static void 00135 terminate(); 00136 00137 explicit 00138 XPathProcessorImpl(); 00139 00140 virtual 00141 ~XPathProcessorImpl(); 00142 00143 00144 // These are inherited from XPathProcessor... 00145 00146 virtual void 00147 initXPath( 00148 XPath& pathObj, 00149 const XalanDOMString& expression, 00150 const PrefixResolver& prefixResolver, 00151 const Locator* locator = 0); 00152 00153 virtual void 00154 initMatchPattern( 00155 XPath& pathObj, 00156 const XalanDOMString& expression, 00157 const PrefixResolver& prefixResolver, 00158 const Locator* locator = 0); 00159 00160 private: 00161 00169 void 00170 tokenize( 00171 const XalanDOMString& pat, 00172 DOMStringVectorType* targetStrings = 0); 00173 00179 bool 00180 mapPatternElemPos( 00181 int nesting, 00182 bool isStart, 00183 bool isAttrName) const; 00184 00188 void 00189 recordTokenString(DOMStringVectorType& targetStrings); 00190 00191 void 00192 addToTokenQueue(const XalanDOMString& s) const; 00193 00198 int 00199 mapNSTokens( 00200 const XalanDOMString& pat, 00201 int startSubstring, 00202 int posOfNSSep, 00203 int posOfScan) const; 00204 00208 int 00209 getTokenQueuePosFromMap(int i) const; 00210 00216 int 00217 getNextTargetIndexInMap(int i) const; 00218 00223 int 00224 getNextIndexInMap(int i) const; 00225 00232 int 00233 getNextSubpatternStartIndexInMap(int i) const; 00234 00240 int 00241 getNextPatternPos(int i) const; 00242 00248 int 00249 getPrevMapIndex(int i) const; 00250 00256 bool 00257 tokenIs(const XalanDOMString& s) const; 00258 00264 bool 00265 tokenIs(const XalanDOMChar* s) const; 00266 00272 bool 00273 tokenIs(const char* s) const; 00274 00280 bool 00281 tokenIs(char c) const; 00282 00290 bool 00291 lookahead( 00292 XalanDOMChar c, 00293 int n) const; 00294 00302 bool 00303 lookahead( 00304 const XalanDOMChar* s, 00305 int n) const; 00306 00314 bool 00315 lookahead( 00316 const XalanDOMString& s, 00317 int n) const; 00318 00329 bool 00330 lookbehind( 00331 char c, 00332 int n) const; 00333 00344 bool 00345 lookbehindHasToken(int n) const; 00346 00351 void 00352 nextToken(); 00353 00358 XalanDOMString 00359 getTokenRelative(int theOffset) const; 00360 00365 void 00366 prevToken(); 00367 00372 void 00373 resetTokenMark(int mark); 00374 00379 void 00380 consumeExpected(const char* expected); 00381 00386 void 00387 consumeExpected(char expected); 00388 00389 bool 00390 isCurrentLiteral() const; 00391 00395 void 00396 error( 00397 const XalanDOMString& msg, 00398 XalanNode* sourceNode = 0) const; 00399 00403 void 00404 error( 00405 const char* msg, 00406 XalanNode* sourceNode = 0) const; 00407 00411 int 00412 getKeywordToken(const XalanDOMString& key) const; 00413 00417 int 00418 getFunctionToken(const XalanDOMString& key) const; 00419 00426 void 00427 Expr(); 00428 00429 00437 void 00438 OrExpr(); 00439 00447 void 00448 AndExpr() ; 00449 00459 int 00460 EqualityExpr(int opCodePos = -1); 00461 00474 int 00475 RelationalExpr(int opCodePos = -1); 00476 00487 int 00488 AdditiveExpr(int opCodePos = -1); 00489 00502 int 00503 MultiplicativeExpr(int opCodePos = -1); 00504 00514 void 00515 UnaryExpr(); 00516 00523 void 00524 BooleanExpr(); 00525 00537 void 00538 UnionExpr(); 00539 00551 void 00552 PathExpr(); 00553 00563 void 00564 FilterExpr(); 00565 00575 void 00576 PrimaryExpr(); 00577 00578 00584 void 00585 Argument(); 00586 00592 void 00593 FunctionCall(); 00594 00601 void 00602 LocationPath(); 00603 00611 void 00612 RelativeLocationPath(); 00613 00619 void 00620 Step(); 00621 00627 void 00628 Basis(); 00629 00635 int 00636 AxisName(); 00637 00644 void 00645 NodeTest(int axisType); 00646 00652 void 00653 Predicate(); 00654 00660 void 00661 PredicateExpr(); 00662 00668 void 00669 QName(); 00670 00675 void 00676 NCName(); 00677 00686 void 00687 Literal(); 00688 00694 void 00695 Number(); 00696 00703 void 00704 Pattern(); 00705 00714 void 00715 LocationPathPattern(); 00716 00724 void 00725 IdKeyPattern(); 00726 00734 void 00735 RelativePathPattern(); 00736 00742 void 00743 StepPattern(); 00744 00750 void 00751 AbbreviatedNodeTestStep(); 00752 00753 bool 00754 isValidFunction(const XalanDOMString& key) const; 00755 00756 private: 00757 00758 int 00759 FunctionCallArguments(); 00760 00761 static void 00762 initializeKeywordsTable(KeywordsMapType& theKeywords); 00763 00764 static void 00765 initializeFunctionTable(FunctionNameMapType& theFunctions); 00766 00767 static void 00768 initializeAxisNamesTable(AxisNamesMapType& theAxisNames); 00769 00770 static void 00771 initializeNodeTypesTable(NodeTypesMapType& theNodeTypes); 00772 00776 XalanDOMString m_token; 00777 00783 XalanDOMChar m_tokenChar; 00784 00788 XPath* m_xpath; 00789 00793 XPathExpression* m_expression; 00794 00798 const PrefixResolver* m_prefixResolver; 00799 00800 bool m_requireLiterals; 00801 00802 const Locator* m_locator; 00803 00804 enum eDummy 00805 { 00806 TARGETEXTRA = 10000 00807 }; 00808 00809 // This shouldn't really be here, since it duplicates a string that is part 00810 // of the information that is maintained by the class XPathFunctionTable, 00811 // but this is a reasonable optimization. 00812 static const XalanDOMString& s_functionIDString; 00813 00814 00815 // This shouldn't really be here, since it's not part of the XPath standard, 00816 // but rather a part ofthe XSLT standard. 00817 static const XalanDOMString& s_functionKeyString; 00818 00819 static const XalanDOMString& s_orString; 00820 00821 static const XalanDOMString& s_andString; 00822 00823 static const XalanDOMString& s_divString; 00824 00825 static const XalanDOMString& s_modString; 00826 00827 static const XalanDOMString& s_dotString; 00828 00829 static const XalanDOMString& s_dotDotString; 00830 00831 static const XalanDOMString& s_axisString; 00832 00833 static const XalanDOMString& s_attributeString; 00834 00835 static const XalanDOMString& s_childString; 00836 00840 static const KeywordsMapType& s_keywords; 00841 00842 static const FunctionNameMapType& s_functions; 00843 00844 static const AxisNamesMapType& s_axisNames; 00845 00846 static const NodeTypesMapType& s_nodeTypes; 00847 }; 00848 00849 00850 00851 #endif // XPATHPROCESSORIMPL_HEADER_GUARD_1357924680
Doxygen and GraphViz are used to generate this API documentation from the Xalan-C header files.
![]() |
Xalan-C++ XSL Transformer Version 1.1 |
|