Xalan-C++ API Documentation

The Xalan C++ XSL Transformer Version 1.1

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 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 XPathEnvSupport&  envSupport);
00152 
00153     virtual void
00154     initMatchPattern(
00155             XPath&                  pathObj,
00156             const XalanDOMString&   expression,
00157             const PrefixResolver&   prefixResolver,
00158             const XPathEnvSupport&  envSupport);
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 
00392     void
00393     warn(
00394             const XalanDOMString&   msg,
00395             XalanNode*              sourceNode = 0) const;
00396 
00400     void
00401     warn(
00402             const char*     msg,
00403             XalanNode*      sourceNode = 0) const;
00404 
00409     void
00410     error(
00411             const XalanDOMString&   msg,
00412             XalanNode*              sourceNode = 0) const;
00413 
00418     void
00419     error(
00420             const char*     msg,
00421             XalanNode*      sourceNode = 0) const;
00422 
00426     int
00427     getKeywordToken(const XalanDOMString&   key) const;
00428 
00432     int
00433     getFunctionToken(const XalanDOMString&  key) const;
00434 
00441     void
00442     Expr();
00443 
00444 
00452     void
00453     OrExpr();
00454 
00462     void
00463     AndExpr() ;
00464   
00474     int
00475     EqualityExpr(int    opCodePos = -1);
00476 
00489     int
00490     RelationalExpr(int  opCodePos = -1);
00491 
00502     int
00503     AdditiveExpr(int    opCodePos = -1);
00504 
00517     int
00518     MultiplicativeExpr(int  opCodePos = -1);
00519 
00529     void
00530     UnaryExpr();
00531   
00537     void
00538     StringExpr();
00539 
00546     void
00547     BooleanExpr();
00548 
00555     void
00556     NumberExpr();
00557   
00569     void
00570     UnionExpr();
00571 
00583     void
00584     PathExpr();
00585 
00595     void
00596     FilterExpr();
00597   
00607     void
00608     PrimaryExpr();
00609 
00610 
00616     void
00617     Argument();
00618   
00624     void
00625     FunctionCall();
00626 
00633     void
00634     LocationPath();
00635   
00643     void
00644     RelativeLocationPath();
00645   
00651     void
00652     Step();
00653   
00659     void
00660     Basis();
00661   
00667     int
00668     AxisName();
00669   
00676     void
00677     NodeTest(int    axisType);
00678 
00684     void
00685     Predicate();
00686 
00692     void
00693     PredicateExpr();
00694   
00700     void
00701     QName();
00702 
00707     void
00708     NCName();
00709   
00718     void
00719     Literal();
00720   
00726     void
00727     Number();
00728 
00735     void
00736     Pattern();
00737 
00746     void
00747     LocationPathPattern();
00748 
00756     void
00757     IdKeyPattern();
00758 
00766     void
00767     RelativePathPattern();
00768 
00774     void
00775     StepPattern();
00776 
00782     void
00783     AbbreviatedNodeTestStep();
00784 
00785     bool
00786     isValidFunction(const XalanDOMString&   key) const;
00787 
00788 private:
00789 
00790     int
00791     FunctionCallArguments();
00792 
00793     static void
00794     initializeKeywordsTable(KeywordsMapType&    theKeywords);
00795 
00796     static void
00797     initializeFunctionTable(FunctionNameMapType&    theFunctions);
00798 
00799     static void
00800     initializeAxisNamesTable(AxisNamesMapType&      theAxisNames);
00801 
00802     static void
00803     initializeNodeTypesTable(NodeTypesMapType&      theNodeTypes);
00804 
00808     XalanDOMString                  m_token;
00809   
00815     XalanDOMChar                    m_tokenChar;
00816 
00820     XPath*                          m_xpath;
00821 
00825     XPathExpression*                m_expression;
00826 
00830     const PrefixResolver*           m_prefixResolver;
00831 
00832     const XPathEnvSupport*          m_envSupport;
00833 
00834     enum eDummy
00835     {
00836         TARGETEXTRA = 10000
00837     };
00838 
00839     // This shouldn't really be here, since it duplicates a string that is part
00840     // of the information that is maintained by the class XPathFunctionTable,
00841     // but this is a reasonable optimization.
00842     static const XalanDOMString&    s_functionIDString;
00843 
00844 
00845     // This shouldn't really be here, since it's not part of the XPath standard,
00846     // but rather a part ofthe XSLT standard.
00847     static const XalanDOMString&    s_functionKeyString;
00848 
00849     static const XalanDOMString&    s_orString;
00850 
00851     static const XalanDOMString&    s_andString;
00852 
00853     static const XalanDOMString&    s_divString;
00854 
00855     static const XalanDOMString&    s_modString;
00856 
00857     static const XalanDOMString&    s_quoString;
00858 
00859     static const XalanDOMString&    s_dotString;
00860 
00861     static const XalanDOMString&    s_dotDotString;
00862 
00863     static const XalanDOMString&    s_axisString;
00864 
00865     static const XalanDOMString&    s_attributeString;
00866 
00867     static const XalanDOMString&    s_childString;
00868 
00872     static const KeywordsMapType&       s_keywords;
00873 
00874     static const FunctionNameMapType&   s_functions;
00875 
00876     static const AxisNamesMapType&      s_axisNames;
00877 
00878     static const NodeTypesMapType&      s_nodeTypes;
00879 };
00880 
00881 
00882 
00883 #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++ XSL Transformer Version 1.1
Copyright © 2000, 2001 The Apache Software Foundation. All Rights Reserved.