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  

XPath.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(XPATH_HEADER_GUARD_1357924680)
00058 #define XPATH_HEADER_GUARD_1357924680
00059 
00060 
00061 
00062 // Base header file.  Must be first.
00063 #include <XPath/XPathDefinitions.hpp>
00064 
00065 
00066 
00067 #include <XalanDOM/XalanDOMString.hpp>
00068 
00069 
00070 
00071 #include <PlatformSupport/DoubleSupport.hpp>
00072 
00073 
00074 
00075 // Base class header files...
00076 #include <XPath/XPathExecutionContext.hpp>
00077 
00078 
00079 
00080 #include <XPath/XPathExpression.hpp>
00081 #include <XPath/Function.hpp>
00082 #include <XPath/XPathFunctionTable.hpp>
00083 
00084 
00085 
00086 class Locator;
00087 class PrefixResolver;
00088 class XObject;
00089 class XalanNode;
00090 
00091 
00092 
00093 class XALAN_XPATH_EXPORT XPath
00094 {
00095 public:
00096 
00097     static const XalanDOMString&    PSEUDONAME_ANY;
00098     static const XalanDOMString&    PSEUDONAME_ROOT;
00099     static const XalanDOMString&    PSEUDONAME_TEXT;
00100     static const XalanDOMString&    PSEUDONAME_COMMENT;
00101     static const XalanDOMString&    PSEUDONAME_PI;
00102     static const XalanDOMString&    PSEUDONAME_OTHER;
00103     static const XalanDOMString&    PSEUDONAME_NODE;
00104 
00105 #if defined(XALAN_NO_NAMESPACES)
00106     typedef vector<XalanDOMString>          TargetElementStringsVectorType;
00107 #else
00108     typedef std::vector<XalanDOMString>     TargetElementStringsVectorType;
00109 #endif
00110 
00111 
00115     static void
00116     initialize();
00117 
00121     static void
00122     terminate();
00123 
00129     explicit
00130     XPath(const Locator*    theLocator = 0);
00131 
00132     virtual
00133     ~XPath();
00134 
00138     void
00139     shrink();
00140 
00149     const XObjectPtr
00150     execute(
00151             XalanNode*              context,
00152             const PrefixResolver&   prefixResolver,
00153             XPathExecutionContext&  executionContext) const;
00154 
00164     const XObjectPtr
00165     execute(
00166             XalanNode*              context,
00167             const PrefixResolver&   prefixResolver,
00168             const NodeRefListBase&  contextNodeList,
00169             XPathExecutionContext&  executionContext) const
00170     {
00171         // Set and restore the context node list...
00172         XPathExecutionContext::ContextNodeListSetAndRestore     theSetAndRestore(
00173                                         executionContext,
00174                                         contextNodeList);   
00175 
00176         return execute(context, prefixResolver, executionContext);
00177     }
00178 
00187     const XObjectPtr
00188     execute(XPathExecutionContext&  executionContext) const
00189     {
00190         assert(executionContext.getPrefixResolver() != 0);
00191 
00192         return executeMore(executionContext.getCurrentNode(), 0, executionContext);
00193     }
00194 
00203     const XObjectPtr
00204     executeMore(
00205             XalanNode*              context,
00206             int                     opPos,
00207             XPathExecutionContext&  executionContext) const;
00208 
00217     const XObjectPtr
00218     locationPath(
00219             XalanNode*              context,
00220             int                     opPos,
00221             XPathExecutionContext&  executionContext) const;
00222 
00228     XPathExpression&
00229     getExpression()
00230     {
00231         return m_expression;
00232     }
00233 
00239     const XPathExpression&
00240     getExpression() const
00241     {
00242         return m_expression;
00243     }
00244 
00245     enum eMatchScore
00246     {
00247         eMatchScoreNone,
00248         eMatchScoreNodeTest,
00249         eMatchScoreNSWild,
00250         eMatchScoreQName,
00251         eMatchScoreOther
00252     };
00253 
00254     static double
00255     getMatchScoreValue(eMatchScore  score)
00256     {
00257         switch(score)
00258         {
00259         case eMatchScoreNone:
00260             return DoubleSupport::getNegativeInfinity();
00261             break;
00262 
00263         case eMatchScoreNodeTest:
00264             return -0.5;
00265             break;
00266 
00267         case eMatchScoreNSWild:
00268             return -0.25;
00269             break;
00270 
00271         case eMatchScoreOther:
00272             return 0.5;
00273             break;
00274 
00275         case eMatchScoreQName:
00276             return 0.0;
00277             break;
00278         };
00279 
00280         assert(false);
00281         return 0.0;
00282     }
00283 
00292     eMatchScore
00293     getMatchScore(
00294             XalanNode*              node,
00295             const PrefixResolver&   resolver,
00296             XPathExecutionContext&  executionContext) const;
00297 
00306     const XObjectPtr
00307     predicate(
00308             XalanNode*              context,
00309             int                     opPos,
00310             XPathExecutionContext&  executionContext) const
00311     {
00312         return executeMore(context, opPos + 2, executionContext);
00313     }
00314 
00320     void
00321     getTargetElementStrings(TargetElementStringsVectorType&     targetStrings) const;
00322 
00329     static void
00330     installFunction(
00331             const XalanDOMString&   funcName,
00332             const Function&         func);
00333 
00340     static bool
00341     uninstallFunction(const XalanDOMString&     funcName);
00342 
00349     static bool
00350     isInstalledFunction(const XalanDOMString&   theFunctionName)
00351     {
00352         return s_functions.isInstalledFunction(theFunctionName);
00353     }
00354 
00355     typedef XPathFunctionTable  FunctionTableType;
00356 
00362     static const FunctionTableType&
00363     getFunctionTable()
00364     {
00365         return s_functions;
00366     }
00367 
00368 #if defined(XALAN_NO_MEMBER_TEMPLATES)
00369     typedef XPathFunctionTable::InstalledFunctionNameVectorType
00370                     InstalledFunctionNameVectorType;
00371 
00377     static void
00378     getInstalledFunctionNames(InstalledFunctionNameVectorType&  theVector)
00379     {
00380         s_functions.getInstalledFunctionNames(theVector);
00381     }
00382 #else
00383 
00388     template<class OutputIteratorType>
00389     static void
00390     getInstalledFunctionNames(OutputIteratorType    theIterator)
00391     {
00392         s_functions.getInstalledFunctionNames(theIterator);
00393     }
00394 #endif
00395 
00396     static void
00397     destroyTable()
00398     {
00399         s_functions.DestroyTable();
00400     }
00401 
00402     bool
00403     getInStylesheet() const
00404     {
00405         return m_inStylesheet;
00406     }
00407 
00408     void
00409     setInStylesheet(bool    fValue)
00410     {
00411         m_inStylesheet = fValue;
00412     }
00413 
00414     const Locator*
00415     getLocator() const
00416     {
00417         return m_locator;
00418     }
00419 
00420     void
00421     setLocator(const Locator*   theLocator)
00422     {
00423         m_locator = theLocator;
00424     }
00425 
00426 protected:
00427 
00431     XLocator*
00432     createXLocatorHandler() const;
00433 
00440     const XObjectPtr
00441     matchPattern(
00442             XalanNode*              context,
00443             int                     opPos,
00444             XPathExecutionContext&  executionContext) const;
00445 
00446 protected:
00447 
00454     void
00455     doGetMatchScore(
00456             XalanNode*              context,
00457             XPathExecutionContext&  executionContext,
00458             eMatchScore&            score) const;
00459 
00466     const XObjectPtr
00467     Or(
00468             XalanNode*              context,
00469             int                     opPos,
00470             XPathExecutionContext&  executionContext) const;
00471 
00478     const XObjectPtr
00479     And(
00480             XalanNode*              context,
00481             int                     opPos,
00482             XPathExecutionContext&  executionContext) const;
00483 
00490     const XObjectPtr
00491     notequals(
00492             XalanNode*              context,
00493             int                     opPos,
00494             XPathExecutionContext&  executionContext) const;
00495 
00502     const XObjectPtr
00503     equals(
00504             XalanNode*              context,
00505             int                     opPos,
00506             XPathExecutionContext&  executionContext) const;
00507 
00514     const XObjectPtr
00515     lte(
00516             XalanNode*              context,
00517             int                     opPos,
00518             XPathExecutionContext&  executionContext) const;
00519 
00526     const XObjectPtr
00527     lt(
00528             XalanNode*              context,
00529             int                     opPos,
00530             XPathExecutionContext&  executionContext) const;
00531 
00538     const XObjectPtr
00539     gte(
00540             XalanNode*              context,
00541             int                     opPos,
00542             XPathExecutionContext&  executionContext) const;
00543 
00550     const XObjectPtr
00551     gt(
00552             XalanNode*              context,
00553             int                     opPos,
00554             XPathExecutionContext&  executionContext) const;
00555 
00562     const XObjectPtr
00563     plus(
00564             XalanNode*              context,
00565             int                     opPos,
00566             XPathExecutionContext&  executionContext) const;
00567 
00574     const XObjectPtr
00575     minus(
00576             XalanNode*              context,
00577             int                     opPos,
00578             XPathExecutionContext&  executionContext) const;
00579 
00586     const XObjectPtr
00587     mult(
00588             XalanNode*              context,
00589             int                     opPos,
00590             XPathExecutionContext&  executionContext) const;
00591 
00598     const XObjectPtr
00599     div(
00600             XalanNode*              context,
00601             int                     opPos,
00602             XPathExecutionContext&  executionContext) const;
00603 
00610     const XObjectPtr
00611     mod(
00612             XalanNode*              context,
00613             int                     opPos,
00614             XPathExecutionContext&  executionContext) const;
00615 
00622     const XObjectPtr
00623     neg(
00624             XalanNode*              context,
00625             int                     opPos,
00626             XPathExecutionContext&  executionContext) const;
00627 
00634     const XObjectPtr
00635     string(
00636             XalanNode*              context,
00637             int                     opPos,
00638             XPathExecutionContext&  executionContext) const;
00639 
00646     const XObjectPtr
00647     boolean(
00648             XalanNode*              context,
00649             int                     opPos,
00650             XPathExecutionContext&  executionContext) const;
00651  
00658     const XObjectPtr
00659     Union(
00660             XalanNode*              context,
00661             int                     opPos,
00662             XPathExecutionContext&  executionContext) const;
00663 
00670     const XObjectPtr
00671     literal(
00672             XalanNode*              context,
00673             int                     opPos,
00674             XPathExecutionContext&  executionContext) const;
00675   
00682     const XObjectPtr
00683     variable(
00684             XalanNode*              context,
00685             int                     opPos,
00686             XPathExecutionContext&  executionContext) const;
00687 
00694     const XObjectPtr
00695     group(
00696             XalanNode*              context,
00697             int                     opPos,
00698             XPathExecutionContext&  executionContext) const
00699     {
00700         return executeMore(context, opPos + 2, executionContext);
00701     }
00702 
00709     const XObjectPtr
00710     numberlit(
00711             XalanNode*              context,
00712             int                     opPos,
00713             XPathExecutionContext&  executionContext) const;
00714 
00721     const XObjectPtr
00722     arg(
00723             XalanNode*              context,
00724             int                     opPos,
00725             XPathExecutionContext&  executionContext) const
00726     {
00727         return executeMore(context, opPos + 2, executionContext);
00728     }
00729 
00737     const XObjectPtr
00738     locationPathPattern(
00739             XalanNode*              context,
00740             int                     opPos,
00741             XPathExecutionContext&  executionContext) const;
00742 
00746     const XObjectPtr
00747     runExtFunction(
00748             XalanNode*              context,
00749             int                     opPos,
00750             XPathExecutionContext&  executionContext) const;
00751 
00755     const XObjectPtr
00756     extfunction(
00757             XalanNode*                              context,
00758             int                                     /* opPos */,
00759             const XalanDOMString&                   theNamespace,
00760             const XalanDOMString&                   functionName, 
00761             const Function::XObjectArgVectorType&   argVec,
00762             XPathExecutionContext&                  executionContext) const
00763     {
00764         return  executionContext.extFunction(theNamespace,
00765                                              functionName,
00766                                              context,
00767                                              argVec);
00768     }
00769 
00773     const XObjectPtr
00774     runFunction(
00775             XalanNode*              context,
00776             int                     opPos,
00777             XPathExecutionContext&  executionContext) const;
00778 
00782     const XObjectPtr
00783     function(
00784             XalanNode*                              context,
00785             int                                     opPos,
00786             int                                     funcID,
00787             const Function::XObjectArgVectorType&   argVec,
00788             XPathExecutionContext&                  executionContext) const
00789     {
00790         return s_functions[funcID].execute(executionContext, context, opPos, argVec);
00791     }
00792 
00793     double
00794     getNumericOperand(
00795             XalanNode*              context,
00796             int                     opPos,
00797             XPathExecutionContext&  executionContext) const;
00798 
00799 private:
00800 
00801     // These are not implemented...
00802     XPath(const XPath&);
00803 
00804     XPath&
00805     operator=(const XPath&);
00806 
00807     bool
00808     operator==(const XPath&) const;
00809 
00810     // Default vector allocation sizes.
00811     enum
00812     {
00813         eDefaultTargetStringsSize = 5
00814     };
00815 
00816     // Data members...
00817 
00823     XPathExpression                     m_expression;
00824 
00828     const Locator*                      m_locator;
00829 
00835     bool                                m_inStylesheet;
00836 
00842     static FunctionTableType            s_functions;
00843 };
00844 
00845 
00846 
00847 #endif  // XPATH_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.