Xalan-C++ API Documentation

The Xalan C++ XSLT Processor Version 1.7

Main Page   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-2004 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 <xalanc/XPath/XPathDefinitions.hpp>
00064 
00065 
00066 
00067 #include <cstdlib>
00068 #include <map>
00069 #include <vector>
00070 
00071 
00072 
00073 #include <xalanc/XalanDOM/XalanDOMString.hpp>
00074 
00075 
00076 
00077 // Base class header file...
00078 #include <xalanc/XPath/XPathProcessor.hpp>
00079 
00080 
00081 
00082 #include <xalanc/XPath/XPath.hpp>
00083 
00084 
00085 
00086 XALAN_CPP_NAMESPACE_BEGIN
00087 
00088 
00089 
00090 class XalanNode;
00091 
00092 
00093 
00098 class XALAN_XPATH_EXPORT XPathProcessorImpl : public XPathProcessor
00099 {
00100 public:
00101 
00102 #if defined(XALAN_NO_STD_NAMESPACE)
00103     typedef map<XalanDOMString,
00104                 const XalanDOMString*,
00105                 less<XalanDOMString> >  StringToStringMapType;
00106 
00107 #if defined(XALAN_USE_DEQUE_FOR_VECTOR_BOOL)
00108     typedef deque<bool>                 BoolVectorType;
00109 #else
00110     typedef vector<bool>                BoolVectorType;
00111 #endif
00112 #else
00113     typedef std::map<XalanDOMString,
00114                      const XalanDOMString*>     StringToStringMapType;
00115 
00116 #if defined(XALAN_USE_DEQUE_FOR_VECTOR_BOOL)
00117     typedef std::deque<bool>            BoolVectorType;
00118 #else
00119     typedef std::vector<bool>           BoolVectorType;
00120 #endif
00121 #endif
00122 
00123     XPathProcessorImpl();
00124 
00125     virtual
00126     ~XPathProcessorImpl();
00127 
00128 
00129     // These are inherited from XPathProcessor...
00130 
00131     virtual void
00132     initXPath(
00133             XPath&                      pathObj,
00134             XPathConstructionContext&   constructionContext,
00135             const XalanDOMString&       expression,
00136             const PrefixResolver&       resolver,
00137             const LocatorType*          locator = 0);
00138 
00139     virtual void
00140     initMatchPattern(
00141             XPath&                      pathObj,
00142             XPathConstructionContext&   constructionContext,
00143             const XalanDOMString&       expression,
00144             const PrefixResolver&       resolver,
00145             const LocatorType*          locator = 0);
00146 
00147 private:
00148 
00155     void
00156     tokenize(const XalanDOMString&  pat);
00157   
00158     void
00159     addToTokenQueue(const XalanDOMString&   s) const;
00160 
00161     void
00162     replaceTokenWithNamespaceToken() const;
00163 
00168     int
00169     mapNSTokens(
00170             const XalanDOMString&   pat,
00171             int                     startSubstring,
00172             int                     posOfNSSep,
00173             int                     posOfScan);
00174 
00180     bool
00181     tokenIs(const XalanDOMString&   s) const;
00182 
00188     bool
00189     tokenIs(const XalanDOMChar*     s) const;
00190 
00196     bool
00197     tokenIs(XalanDOMChar    c) const;
00198 
00206     bool
00207     lookahead(
00208             XalanDOMChar    c,
00209             int             n) const;
00210 
00218     bool
00219     lookahead(
00220             const XalanDOMChar*     s,
00221             int                     n) const;
00222 
00230     bool
00231     lookahead(
00232             const XalanDOMString&   s,
00233             int                     n) const;
00234 
00245     bool
00246     lookbehind( 
00247             char    c,
00248             int     n) const;
00249 
00260     bool
00261     lookbehindHasToken(int  n) const;
00262 
00267     void
00268     nextToken();
00269 
00274     const XalanDOMString&
00275     getTokenRelative(int    theOffset) const;
00276 
00281     void
00282     prevToken();
00283 
00288     void
00289     resetTokenMark(int  mark);
00290 
00295     void
00296     consumeExpected(XalanDOMChar    expected);
00297 
00298     bool
00299     isCurrentLiteral() const;
00300 
00307     static bool
00308     isAxis(const XalanDOMString&    theToken);
00309 
00316     static bool
00317     isNodeTest(const XalanDOMString&    theToken);
00318 
00322     void
00323     error(const XalanDOMString&     msg) const;
00324 
00328     void
00329     error(const char*   msg) const;
00330 
00334     static XPathExpression::eOpCodes
00335     getFunctionToken(const XalanDOMString&  key)
00336     {
00337         return searchTable(s_functionTable, s_functionTableSize, key).m_opCode;
00338     }
00339 
00343     static XPathExpression::eOpCodes
00344     getNodeTypeToken(const XalanDOMString&  key)
00345     {
00346         return searchTable(s_nodeTypeTable, s_nodeTypeTableSize, key).m_opCode;
00347     }
00348 
00352     static XPathExpression::eOpCodes
00353     getAxisToken(const XalanDOMString&  key)
00354     {
00355         return searchTable(s_axisTable, s_axisTableSize, key).m_opCode;
00356     }
00357 
00364     void
00365     Expr();
00366 
00367 
00375     void
00376     OrExpr();
00377 
00385     void
00386     AndExpr() ;
00387   
00397     int
00398     EqualityExpr(int    opCodePos = -1);
00399 
00412     int
00413     RelationalExpr(int  opCodePos = -1);
00414 
00425     int
00426     AdditiveExpr(int    opCodePos = -1);
00427 
00440     int
00441     MultiplicativeExpr(int  opCodePos = -1);
00442 
00452     void
00453     UnaryExpr();
00454 
00466     void
00467     UnionExpr();
00468 
00480     void
00481     PathExpr();
00482 
00492     void
00493     FilterExpr();
00494   
00504     void
00505     PrimaryExpr();
00506 
00507 
00513     void
00514     Argument();
00515   
00521     void
00522     FunctionCall();
00523 
00524     void
00525     FunctionPosition();
00526 
00527     void
00528     FunctionLast();
00529 
00530     void
00531     FunctionCount();
00532 
00533     void
00534     FunctionNot();
00535 
00536     void
00537     FunctionTrue();
00538 
00539     void
00540     FunctionFalse();
00541 
00542     void
00543     FunctionBoolean();
00544 
00545     void
00546     FunctionName(int    opPos);
00547 
00548     void
00549     FunctionLocalName(int   opPos);
00550 
00551     void
00552     FunctionNumber(int  opPos);
00553 
00554     void
00555     FunctionFloor();
00556 
00557     void
00558     FunctionCeiling();
00559 
00560     void
00561     FunctionRound();
00562 
00563     void
00564     FunctionString(int  opPos);
00565 
00566     void
00567     FunctionStringLength(int    opPos);
00568 
00569     void
00570     FunctionSum();
00571 
00572     void
00573     FunctionNamespaceURI(int    opPos);
00574 
00581     void
00582     LocationPath();
00583   
00591     void
00592     RelativeLocationPath();
00593   
00599     void
00600     Step();
00601   
00607     void
00608     Basis();
00609   
00615     XPathExpression::eOpCodes
00616     AxisName();
00617   
00624     int
00625     NodeTest();
00626 
00632     void
00633     Predicate();
00634 
00640     void
00641     PredicateExpr();
00642   
00648     void
00649     QName();
00650 
00655     void
00656     NCName();
00657   
00666     void
00667     Literal();
00668   
00674     void
00675     Number();
00676 
00683     void
00684     Pattern();
00685 
00694     void
00695     LocationPathPattern();
00696 
00704     void
00705     IdKeyPattern();
00706 
00714     void
00715     RelativePathPattern();
00716 
00722     void
00723     StepPattern();
00724 
00730     void
00731     AbbreviatedNodeTestStep();
00732 
00733     static bool
00734     isValidFunction(const XalanDOMString&   key);
00735 
00736 private:
00737 
00738     int
00739     FunctionCallArguments();
00740 
00741     struct TableEntry
00742     {
00743         const XalanDOMChar*         m_string;
00744 
00745         XPathExpression::eOpCodes   m_opCode;
00746     };
00747 
00748 #if defined(XALAN_STRICT_ANSI_HEADERS)
00749     typedef std::size_t             size_type;
00750 #else
00751     typedef size_t                  size_type;
00752 #endif
00753 
00754     static const TableEntry&
00755     searchTable(
00756         const TableEntry        theTable[],
00757         size_type               theTableSize,
00758         const XalanDOMString&   theString);
00759 
00763     XalanDOMString                  m_token;
00764   
00770     XalanDOMChar                    m_tokenChar;
00771 
00775     XPath*                          m_xpath;
00776 
00780     XPathConstructionContext*       m_constructionContext;
00781 
00785     XPathExpression*                m_expression;
00786 
00790     const PrefixResolver*           m_prefixResolver;
00791 
00792     bool                            m_requireLiterals;
00793 
00794     bool                            m_isMatchPattern;
00795 
00796     const LocatorType*              m_locator;
00797 
00798     BoolVectorType                  m_positionPredicateStack;
00799 
00800     StringToStringMapType           m_namespaces;
00801 
00802 
00803     // Static stuff here...
00804     static const XalanDOMString     s_emptyString;
00805 
00806     static const XalanDOMChar       s_functionIDString[];
00807 
00808     // This shouldn't really be here, since it's not part of the XPath standard,
00809     // but rather a part ofthe XSLT standard.
00810     static const XalanDOMChar       s_functionKeyString[];
00811 
00812     static const XalanDOMChar       s_orString[];
00813 
00814     static const XalanDOMChar       s_andString[];
00815 
00816     static const XalanDOMChar       s_divString[];
00817 
00818     static const XalanDOMChar       s_modString[];
00819 
00820     static const XalanDOMChar       s_dotString[];
00821 
00822     static const XalanDOMChar       s_dotDotString[];
00823 
00824     static const XalanDOMChar       s_axisString[];
00825 
00826     static const XalanDOMChar       s_attributeString[];
00827 
00828     static const XalanDOMChar       s_childString[];
00829 
00830     static const XalanDOMChar       s_lastString[];
00831 
00832     static const XalanDOMChar       s_positionString[];
00833 
00834     static const XalanDOMChar       s_asteriskString[];
00835 
00836     static const XalanDOMChar       s_commentString[];
00837 
00838     static const XalanDOMChar       s_piString[];
00839 
00840     static const XalanDOMChar       s_nodeString[];
00841 
00842     static const XalanDOMChar       s_textString[];
00843 
00844     static const XalanDOMChar       s_ancestorString[];
00845 
00846     static const XalanDOMChar       s_ancestorOrSelfString[];
00847 
00848     static const XalanDOMChar       s_descendantString[];
00849 
00850     static const XalanDOMChar       s_descendantOrSelfString[];
00851 
00852     static const XalanDOMChar       s_followingString[];
00853 
00854     static const XalanDOMChar       s_followingSiblingString[];
00855 
00856     static const XalanDOMChar       s_parentString[];
00857 
00858     static const XalanDOMChar       s_precedingString[];
00859 
00860     static const XalanDOMChar       s_precedingSiblingString[];
00861 
00862     static const XalanDOMChar       s_selfString[];
00863 
00864     static const XalanDOMChar       s_namespaceString[];
00865 
00866     static const TableEntry         s_functionTable[];
00867 
00868     static const size_type          s_functionTableSize;
00869 
00870     static const TableEntry         s_nodeTypeTable[];
00871 
00872     static const size_type          s_nodeTypeTableSize;
00873 
00874     static const TableEntry         s_axisTable[];
00875 
00876     static const size_type          s_axisTableSize;
00877 
00878     static const TableEntry         s_dummyEntry;
00879 };
00880 
00881 
00882 
00883 XALAN_CPP_NAMESPACE_END
00884 
00885 
00886 
00887 #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.7
Copyright © 1999-2004 The Apache Software Foundation. All Rights Reserved.