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 const 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 00398 static bool 00399 isAxis(const XalanDOMString& theToken); 00400 00407 static bool 00408 isNodeTest(const XalanDOMString& theToken); 00409 00413 void 00414 error( 00415 const XalanDOMString& msg, 00416 XalanNode* sourceNode = 0) const; 00417 00421 void 00422 error( 00423 const char* msg, 00424 XalanNode* sourceNode = 0) const; 00425 00429 int 00430 getKeywordToken(const XalanDOMString& key) const; 00431 00435 int 00436 getFunctionToken(const XalanDOMString& key) const; 00437 00444 void 00445 Expr(); 00446 00447 00455 void 00456 OrExpr(); 00457 00465 void 00466 AndExpr() ; 00467 00477 int 00478 EqualityExpr(int opCodePos = -1); 00479 00492 int 00493 RelationalExpr(int opCodePos = -1); 00494 00505 int 00506 AdditiveExpr(int opCodePos = -1); 00507 00520 int 00521 MultiplicativeExpr(int opCodePos = -1); 00522 00532 void 00533 UnaryExpr(); 00534 00541 void 00542 BooleanExpr(); 00543 00555 void 00556 UnionExpr(); 00557 00569 void 00570 PathExpr(); 00571 00581 void 00582 FilterExpr(); 00583 00593 void 00594 PrimaryExpr(); 00595 00596 00602 void 00603 Argument(); 00604 00610 void 00611 FunctionCall(); 00612 00619 void 00620 LocationPath(); 00621 00629 void 00630 RelativeLocationPath(); 00631 00637 void 00638 Step(); 00639 00645 void 00646 Basis(); 00647 00653 int 00654 AxisName(); 00655 00662 void 00663 NodeTest(int axisType); 00664 00670 void 00671 Predicate(); 00672 00678 void 00679 PredicateExpr(); 00680 00686 void 00687 QName(); 00688 00693 void 00694 NCName(); 00695 00704 void 00705 Literal(); 00706 00712 void 00713 Number(); 00714 00721 void 00722 Pattern(); 00723 00732 void 00733 LocationPathPattern(); 00734 00742 void 00743 IdKeyPattern(); 00744 00752 void 00753 RelativePathPattern(); 00754 00760 void 00761 StepPattern(); 00762 00768 void 00769 AbbreviatedNodeTestStep(); 00770 00771 bool 00772 isValidFunction(const XalanDOMString& key) const; 00773 00774 private: 00775 00776 int 00777 FunctionCallArguments(); 00778 00779 static void 00780 initializeKeywordsTable(KeywordsMapType& theKeywords); 00781 00782 static void 00783 initializeFunctionTable(FunctionNameMapType& theFunctions); 00784 00785 static void 00786 initializeAxisNamesTable(AxisNamesMapType& theAxisNames); 00787 00788 static void 00789 initializeNodeTypesTable(NodeTypesMapType& theNodeTypes); 00790 00794 XalanDOMString m_token; 00795 00801 XalanDOMChar m_tokenChar; 00802 00806 XPath* m_xpath; 00807 00811 XPathExpression* m_expression; 00812 00816 const PrefixResolver* m_prefixResolver; 00817 00818 bool m_requireLiterals; 00819 00820 const Locator* m_locator; 00821 00822 enum eDummy 00823 { 00824 TARGETEXTRA = 10000 00825 }; 00826 00827 static const XalanDOMString s_emptyString; 00828 00829 // This shouldn't really be here, since it duplicates a string that is part 00830 // of the information that is maintained by the class XPathFunctionTable, 00831 // but this is a reasonable optimization. 00832 static const XalanDOMString& s_functionIDString; 00833 00834 00835 // This shouldn't really be here, since it's not part of the XPath standard, 00836 // but rather a part ofthe XSLT standard. 00837 static const XalanDOMString& s_functionKeyString; 00838 00839 static const XalanDOMString& s_orString; 00840 00841 static const XalanDOMString& s_andString; 00842 00843 static const XalanDOMString& s_divString; 00844 00845 static const XalanDOMString& s_modString; 00846 00847 static const XalanDOMString& s_dotString; 00848 00849 static const XalanDOMString& s_dotDotString; 00850 00851 static const XalanDOMString& s_axisString; 00852 00853 static const XalanDOMString& s_attributeString; 00854 00855 static const XalanDOMString& s_childString; 00856 00860 static const KeywordsMapType& s_keywords; 00861 00862 static const FunctionNameMapType& s_functions; 00863 00864 static const AxisNamesMapType& s_axisNames; 00865 00866 static const NodeTypesMapType& s_nodeTypes; 00867 }; 00868 00869 00870 00871 #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.3 |
|