Xalan-C++ API Documentation

The Xalan-C++ XSL Transformer Version 1.0

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 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(char    c) const;
00274 
00282     bool
00283     lookahead(
00284             XalanDOMChar    c,
00285             int             n) const;
00286 
00294     bool
00295     lookahead(
00296             const XalanDOMChar*     s,
00297             int                     n) const;
00298 
00306     bool
00307     lookahead(
00308             const XalanDOMString&   s,
00309             int                     n) const;
00310 
00321     bool
00322     lookbehind( 
00323             char    c,
00324             int     n) const;
00325  
00336     bool
00337     lookbehindHasToken(int  n) const;
00338 
00343     void
00344     nextToken();
00345 
00350     XalanDOMString
00351     getTokenRelative(int    theOffset) const;
00352 
00357     void
00358     prevToken();
00359 
00364     void
00365     resetTokenMark(int  mark);
00366   
00371     void
00372     consumeExpected(const char*     expected);
00373 
00378     void
00379     consumeExpected(char    expected);
00380 
00384     void
00385     warn(
00386             const XalanDOMString&   msg,
00387             XalanNode*              sourceNode = 0) const;
00388 
00393     void
00394     error(
00395             const XalanDOMString&   msg,
00396             XalanNode*              sourceNode = 0) const;
00397 
00401     int
00402     getKeywordToken(const XalanDOMString&   key) const;
00403 
00407     int
00408     getFunctionToken(const XalanDOMString&  key) const;
00409 
00416     void
00417     Expr();
00418 
00419 
00427     void
00428     OrExpr();
00429 
00437     void
00438     AndExpr() ;
00439   
00449     int
00450     EqualityExpr(int    opCodePos = -1);
00451 
00464     int
00465     RelationalExpr(int  opCodePos = -1);
00466 
00477     int
00478     AdditiveExpr(int    opCodePos = -1);
00479 
00492     int
00493     MultiplicativeExpr(int  opCodePos = -1);
00494 
00504     void
00505     UnaryExpr();
00506   
00512     void
00513     StringExpr();
00514 
00521     void
00522     BooleanExpr();
00523 
00530     void
00531     NumberExpr();
00532   
00544     void
00545     UnionExpr();
00546 
00558     void
00559     PathExpr();
00560 
00570     void
00571     FilterExpr();
00572   
00582     void
00583     PrimaryExpr();
00584 
00585 
00591     void
00592     Argument();
00593   
00599     void
00600     FunctionCall();
00601 
00608     void
00609     LocationPath();
00610   
00618     void
00619     RelativeLocationPath();
00620   
00626     void
00627     Step();
00628   
00634     void
00635     Basis();
00636   
00642     int
00643     AxisName();
00644   
00651     void
00652     NodeTest(int    axisType);
00653 
00659     void
00660     Predicate();
00661 
00667     void
00668     PredicateExpr();
00669   
00675     void
00676     QName();
00677 
00682     void
00683     NCName();
00684   
00693     void
00694     Literal();
00695   
00701     void
00702     Number();
00703 
00710     void
00711     Pattern();
00712 
00721     void
00722     LocationPathPattern();
00723 
00731     void
00732     IdKeyPattern();
00733 
00741     void
00742     RelativePathPattern();
00743 
00749     void
00750     StepPattern();
00751 
00757     void
00758     AbbreviatedNodeTestStep();
00759 
00760     bool
00761     isValidFunction(const XalanDOMString&   key) const;
00762 
00763 private:
00764 
00765     int
00766     FunctionCallArguments();
00767 
00768     static void
00769     initializeKeywordsTable(KeywordsMapType&    theKeywords);
00770 
00771     static void
00772     initializeFunctionTable(FunctionNameMapType&    theFunctions);
00773 
00774     static void
00775     initializeAxisNamesTable(AxisNamesMapType&      theAxisNames);
00776 
00777     static void
00778     initializeNodeTypesTable(NodeTypesMapType&      theNodeTypes);
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     const XPathEnvSupport*          m_envSupport;
00808 
00809     enum eDummy
00810     {
00811         TARGETEXTRA = 10000
00812     };
00813 
00814     // This shouldn't really be here, since it duplicates a string that is part
00815     // of the information that is maintained by the class XPathFunctionTable,
00816     // but this is a reasonable optimization.
00817     static const XalanDOMString&    s_functionIDString;
00818 
00819 
00820     // This shouldn't really be here, since it's not part of the XPath standard,
00821     // but rather a part ofthe XSLT standard.
00822     static const XalanDOMString&    s_functionKeyString;
00823 
00824     static const XalanDOMString&    s_orString;
00825 
00826     static const XalanDOMString&    s_andString;
00827 
00828     static const XalanDOMString&    s_divString;
00829 
00830     static const XalanDOMString&    s_modString;
00831 
00832     static const XalanDOMString&    s_quoString;
00833 
00834     static const XalanDOMString&    s_dotString;
00835 
00836     static const XalanDOMString&    s_dotDotString;
00837 
00838     static const XalanDOMString&    s_axisString;
00839 
00840     static const XalanDOMString&    s_attributeString;
00841 
00842     static const XalanDOMString&    s_childString;
00843 
00847     static const KeywordsMapType&       s_keywords;
00848 
00849     static const FunctionNameMapType&   s_functions;
00850 
00851     static const AxisNamesMapType&      s_axisNames;
00852 
00853     static const NodeTypesMapType&      s_nodeTypes;
00854 };
00855 
00856 
00857 
00858 #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.0
Copyright © 2000 The Apache Software Foundation. All Rights Reserved.