Xalan-C++ API Documentation

The Xalan C++ XSLT Processor Version 1.4

Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

XPathProcessorImpl.hpp

Go to the documentation of this file.
00001 /*
00002  * The Apache Software License, Version 1.1
00003  *
00004  *
00005  * Copyright (c) 1999-2002 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 <cstdlib>
00068 #include <map>
00069 #include <vector>
00070 
00071 
00072 
00073 #include <XalanDOM/XalanDOMString.hpp>
00074 
00075 
00076 
00077 // Base class header file...
00078 #include <XPath/XPathProcessor.hpp>
00079 
00080 
00081 
00082 #include <XPath/XPath.hpp>
00083 
00084 
00085 
00086 class XalanNode;
00087 
00088 
00089 
00094 class XALAN_XPATH_EXPORT XPathProcessorImpl : public XPathProcessor
00095 {
00096 public:
00097 
00098 #if defined(XALAN_NO_NAMESPACES)
00099     typedef map<XalanDOMString,
00100                 XalanDOMString,
00101                 less<XalanDOMString> >  StringToStringMapType;
00102 
00103     typedef vector<bool>                BoolVectorType;
00104 #else
00105     typedef std::map<XalanDOMString,
00106                      XalanDOMString>    StringToStringMapType;
00107 
00108     typedef std::vector<bool>           BoolVectorType;
00109 #endif
00110 
00111     XPathProcessorImpl();
00112 
00113     virtual
00114     ~XPathProcessorImpl();
00115 
00116 
00117     // These are inherited from XPathProcessor...
00118 
00119     virtual void
00120     initXPath(
00121             XPath&                  pathObj,
00122             const XalanDOMString&   expression,
00123             const PrefixResolver&   prefixResolver,
00124             const Locator*          locator = 0);
00125 
00126     virtual void
00127     initMatchPattern(
00128             XPath&                  pathObj,
00129             const XalanDOMString&   expression,
00130             const PrefixResolver&   prefixResolver,
00131             const Locator*          locator = 0);
00132 
00133 private:
00134 
00141     void
00142     tokenize(const XalanDOMString&  pat);
00143   
00149     bool
00150     mapPatternElemPos(
00151             int     nesting,
00152             bool    isStart,
00153             bool    isAttrName) const;
00154 
00155     void
00156     addToTokenQueue(const XalanDOMString&   s) const;
00157 
00158     void
00159     replaceTokenWithNamespaceToken() const;
00160 
00165     int
00166     mapNSTokens(
00167             const XalanDOMString&   pat,
00168             int                     startSubstring,
00169             int                     posOfNSSep,
00170             int                     posOfScan);
00171 
00175     int
00176     getTokenQueuePosFromMap(int     i) const;
00177 
00183     int
00184     getNextTargetIndexInMap(int     i) const;
00185   
00190     int
00191     getNextIndexInMap(int   i) const;
00192   
00199     int
00200     getNextSubpatternStartIndexInMap(int    i) const;
00201 
00207     int
00208     getNextPatternPos(int   i) const;
00209 
00215     int
00216     getPrevMapIndex(int     i) const;
00217 
00223     bool
00224     tokenIs(const XalanDOMString&   s) const;
00225 
00231     bool
00232     tokenIs(const XalanDOMChar*     s) const;
00233 
00239     bool
00240     tokenIs(const char*     s) const;
00241 
00247     bool
00248     tokenIs(char    c) const;
00249 
00257     bool
00258     lookahead(
00259             XalanDOMChar    c,
00260             int             n) const;
00261 
00269     bool
00270     lookahead(
00271             const XalanDOMChar*     s,
00272             int                     n) const;
00273 
00281     bool
00282     lookahead(
00283             const XalanDOMString&   s,
00284             int                     n) const;
00285 
00296     bool
00297     lookbehind( 
00298             char    c,
00299             int     n) const;
00300  
00311     bool
00312     lookbehindHasToken(int  n) const;
00313 
00318     void
00319     nextToken();
00320 
00325     const XalanDOMString&
00326     getTokenRelative(int    theOffset) const;
00327 
00332     void
00333     prevToken();
00334 
00339     void
00340     resetTokenMark(int  mark);
00341 
00346     void
00347     consumeExpected(const char*     expected);
00348 
00353     void
00354     consumeExpected(char    expected);
00355 
00356     bool
00357     isCurrentLiteral() const;
00358 
00365     static bool
00366     isAxis(const XalanDOMString&    theToken);
00367 
00374     static bool
00375     isNodeTest(const XalanDOMString&    theToken);
00376 
00380     void
00381     error(
00382             const XalanDOMString&   msg,
00383             XalanNode*              sourceNode = 0) const;
00384 
00388     void
00389     error(
00390             const char*     msg,
00391             XalanNode*      sourceNode = 0) const;
00392 
00396     static XPathExpression::eOpCodes
00397     getFunctionToken(const XalanDOMString&  key)
00398     {
00399         return searchTable(s_functionTable, s_functionTableSize, key).m_opCode;
00400     }
00401 
00405     static XPathExpression::eOpCodes
00406     getNodeTypeToken(const XalanDOMString&  key)
00407     {
00408         return searchTable(s_nodeTypeTable, s_nodeTypeTableSize, key).m_opCode;
00409     }
00410 
00414     static XPathExpression::eOpCodes
00415     getAxisToken(const XalanDOMString&  key)
00416     {
00417         return searchTable(s_axisTable, s_axisTableSize, key).m_opCode;
00418     }
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     XPathExpression::eOpCodes
00636     AxisName();
00637   
00644     int
00645     NodeTest(XPathExpression::eOpCodes  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     static bool
00754     isValidFunction(const XalanDOMString&   key);
00755 
00756 private:
00757 
00758     int
00759     FunctionCallArguments();
00760 
00761     struct TableEntry
00762     {
00763         const XalanDOMChar*         m_string;
00764 
00765         XPathExpression::eOpCodes   m_opCode;
00766     };
00767 
00768 #if defined(XALAN_SIZE_T_IN_NAMESPACE_STD)
00769     typedef std::size_t             size_type;
00770 #else
00771     typedef size_t                  size_type;
00772 #endif
00773 
00774     static const TableEntry&
00775     searchTable(
00776         const TableEntry        theTable[],
00777         size_type               theTableSize,
00778         const XalanDOMString&   theString);
00779 
00783     XalanDOMString                  m_token;
00784   
00790     XalanDOMChar                    m_tokenChar;
00791 
00795     XPath*                          m_xpath;
00796 
00800     XPathExpression*                m_expression;
00801 
00805     const PrefixResolver*           m_prefixResolver;
00806 
00807     bool                            m_requireLiterals;
00808 
00809     bool                            m_isMatchPattern;
00810 
00811     const Locator*                  m_locator;
00812 
00813     BoolVectorType                  m_positionPredicateStack;
00814 
00815     StringToStringMapType           m_namespaces;
00816 
00817     enum eDummy
00818     {
00819         TARGETEXTRA = 10000
00820     };
00821 
00822     static const XalanDOMString     s_emptyString;
00823 
00824     static const XalanDOMChar       s_functionIDString[];
00825 
00826     // This shouldn't really be here, since it's not part of the XPath standard,
00827     // but rather a part ofthe XSLT standard.
00828     static const XalanDOMChar       s_functionKeyString[];
00829 
00830     static const XalanDOMChar       s_orString[];
00831 
00832     static const XalanDOMChar       s_andString[];
00833 
00834     static const XalanDOMChar       s_divString[];
00835 
00836     static const XalanDOMChar       s_modString[];
00837 
00838     static const XalanDOMChar       s_dotString[];
00839 
00840     static const XalanDOMChar       s_dotDotString[];
00841 
00842     static const XalanDOMChar       s_axisString[];
00843 
00844     static const XalanDOMChar       s_attributeString[];
00845 
00846     static const XalanDOMChar       s_childString[];
00847 
00848     static const XalanDOMChar       s_positionString[];
00849 
00850     static const XalanDOMChar       s_asteriskString[];
00851 
00852     static const XalanDOMChar       s_commentString[];
00853 
00854     static const XalanDOMChar       s_piString[];
00855 
00856     static const XalanDOMChar       s_nodeString[];
00857 
00858     static const XalanDOMChar       s_textString[];
00859 
00860     static const XalanDOMChar       s_ancestorString[];
00861 
00862     static const XalanDOMChar       s_ancestorOrSelfString[];
00863 
00864     static const XalanDOMChar       s_descendantString[];
00865 
00866     static const XalanDOMChar       s_descendantOrSelfString[];
00867 
00868     static const XalanDOMChar       s_followingString[];
00869 
00870     static const XalanDOMChar       s_followingSiblingString[];
00871 
00872     static const XalanDOMChar       s_parentString[];
00873 
00874     static const XalanDOMChar       s_precedingString[];
00875 
00876     static const XalanDOMChar       s_precedingSiblingString[];
00877 
00878     static const XalanDOMChar       s_selfString[];
00879 
00880     static const XalanDOMChar       s_namespaceString[];
00881 
00882     static const TableEntry         s_functionTable[];
00883 
00884     static const size_type          s_functionTableSize;
00885 
00886     static const TableEntry         s_nodeTypeTable[];
00887 
00888     static const size_type          s_nodeTypeTableSize;
00889 
00890     static const TableEntry         s_axisTable[];
00891 
00892     static const size_type          s_axisTableSize;
00893 
00894     static const TableEntry         s_dummyEntry;
00895 };
00896 
00897 
00898 
00899 #endif  // XPATHPROCESSORIMPL_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.4
Copyright © 2000, 2001, 2002 The Apache Software Foundation. All Rights Reserved.