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  

XSLTEngineImpl.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(XALAN_XSLTENGINEIMPL_HEADER_GUARD)
00058 #define XALAN_XSLTENGINEIMPL_HEADER_GUARD
00059 
00060 
00061 
00062 // Base include file.  Must be first.
00063 #include "XSLTDefinitions.hpp"
00064 
00065 
00066 
00067 // Base class
00068 #include "XSLTProcessor.hpp"
00069 
00070 
00071 
00072 
00073 // Standard library headers
00074 #include <cassert>
00075 #include <ctime>
00076 #include <map>
00077 #include <set>
00078 
00079 
00080 
00081 #include <xalanc/XalanDOM/XalanDOMString.hpp>
00082 
00083 
00084 
00085 #if defined(XALAN_AUTO_PTR_REQUIRES_DEFINITION)
00086 #include <xalanc/XPath/XPathProcessor.hpp>
00087 #endif
00088 
00089 
00090 
00091 #include <xalanc/Include/XalanAutoPtr.hpp>
00092 
00093 
00094 
00095 #include <xalanc/PlatformSupport/AttributeListImpl.hpp>
00096 #include <xalanc/PlatformSupport/DOMStringHelper.hpp>
00097 #include <xalanc/PlatformSupport/PrefixResolver.hpp>
00098 
00099 
00100 
00101 #include <xalanc/DOMSupport/XalanNamespacesStack.hpp>
00102 
00103 
00104 
00105 #include <xalanc/XPath/Function.hpp>
00106 
00107 
00108 
00109 #include <xalanc/XPath/XPathConstructionContextDefault.hpp>
00110 
00111 
00112 
00113 #include "OutputContextStack.hpp"
00114 #include "ProblemListenerDefault.hpp"
00115 #include "ResultNamespacesStack.hpp"
00116 #include "StylesheetExecutionContext.hpp"
00117 #include "XSLTProcessorException.hpp"
00118 
00119 
00120 
00121 XALAN_DECLARE_XERCES_CLASS(InputSource)
00122 XALAN_DECLARE_XERCES_CLASS(DocumentHandler)
00123 
00124 
00125 
00126 XALAN_CPP_NAMESPACE_BEGIN
00127 
00128 
00129 
00130 typedef XERCES_CPP_NAMESPACE_QUALIFIER InputSource      InputSourceType;
00131 typedef XERCES_CPP_NAMESPACE_QUALIFIER DocumentHandler  DocumentHandlerType;
00132 
00133 
00134 
00135 // Forward declarations...
00136 class DOMSupport;
00137 class GenerateEvent;
00138 class PrintWriter;
00139 class StylesheetConstructionContext;
00140 class StylesheetExecutionContext;
00141 class StylesheetRoot;
00142 class XalanAttr;
00143 class XalanSourceTreeDocument;
00144 class XalanText;
00145 class XMLParserLiaison;
00146 class XObject;
00147 class XPathEnvSupport;
00148 class XPathFactory;
00149 class XPathProcessor;
00150 class XSLTResultTarget;
00151 
00152 
00153 
00165 
00166 class XALAN_XSLT_EXPORT XSLTEngineImpl : public XSLTProcessor, public PrefixResolver
00167 {
00168 public:
00169 
00170 #if defined(XALAN_STRICT_ANSI_HEADERS)
00171     typedef std::clock_t    ClockType;
00172 #else
00173     typedef clock_t         ClockType;
00174 #endif
00175 
00176     struct LessXalanDOMStringPointers
00177     {
00178         bool
00179         operator()(
00180                 const XalanDOMString*   theLHS,
00181                 const XalanDOMString*   theRHS) const
00182         {
00183             if (theLHS == 0 && theRHS != 0)
00184             {
00185                 return true;
00186             }
00187             else if (theRHS == 0)
00188             {
00189                 return false;
00190             }
00191             else
00192             {
00193                 return theLHS->compare(*theRHS) < 0 ? true : false;
00194             }
00195         }
00196     };
00197 
00198 #if defined(XALAN_NO_STD_NAMESPACE)
00199     typedef map<const void*,
00200                 ClockType,
00201                 less<const void*> >         DurationsTableMapType;
00202     typedef vector<const LocatorType*>      LocatorStack;
00203     typedef vector<TraceListener*>          TraceListenerVectorType;
00204 #if defined(XALAN_USE_DEQUE_FOR_VECTOR_BOOL)
00205     typedef deque<bool>                     BoolVectorType;
00206 #else
00207     typedef vector<bool>                    BoolVectorType;
00208 #endif
00209     typedef vector<const XalanDOMString*>   XalanDOMStringPointerVectorType;
00210 #else
00211     typedef std::map<const void*, ClockType>    DurationsTableMapType;
00212     typedef std::vector<const LocatorType*>     LocatorStack;
00213     typedef std::vector<TraceListener*>         TraceListenerVectorType;
00214 #if defined(XALAN_USE_DEQUE_FOR_VECTOR_BOOL)
00215     typedef std::deque<bool>                    BoolVectorType;
00216 #else
00217     typedef std::vector<bool>                   BoolVectorType;
00218 #endif
00219     typedef std::vector<const XalanDOMString*>  XalanDOMStringPointerVectorType;
00220 #endif
00221 
00222     struct FindStringPointerFunctor
00223     {
00224         FindStringPointerFunctor(const XalanDOMString&  theString) :
00225             m_string(theString)
00226         {
00227         }
00228 
00229         bool
00230         operator()(const XalanDOMString*    theString) const
00231         {
00232             assert(theString != 0);
00233 
00234             return *theString == m_string;
00235         }
00236 
00237     private:
00238 
00239         const XalanDOMString&   m_string;
00240     };
00241 
00242     typedef XalanAutoPtr<XPathProcessor>                XPathProcessorPtrType;
00243     typedef Function::XObjectArgVectorType              XObjectArgVectorType;
00244     typedef StylesheetExecutionContext::ParamVectorType ParamVectorType;
00245 
00246     // Public members
00247     //---------------------------------------------------------------------
00248 
00261     XSLTEngineImpl(
00262             XMLParserLiaison&   parserLiaison,
00263             XPathEnvSupport&    xpathEnvSupport,
00264             DOMSupport&         domSupport,
00265             XObjectFactory&     xobjectFactory,
00266             XPathFactory&       xpathFactory);
00267 
00268     virtual
00269     ~XSLTEngineImpl();
00270 
00275     static void
00276     initialize();
00277 
00281     static void
00282     terminate();
00283 
00284     // These methods are inherited from XSLTProcessor ...
00285     
00286     virtual void
00287     process(
00288             const XSLTInputSource&          inputSource, 
00289             const XSLTInputSource&          stylesheetSource,
00290             XSLTResultTarget&               outputTarget,
00291             StylesheetConstructionContext&  constructionContext,
00292             StylesheetExecutionContext&     executionContext);
00293 
00294     virtual void
00295     process(
00296             const XSLTInputSource&          inputSource,
00297             XSLTResultTarget&               outputTarget,
00298             StylesheetExecutionContext&     executionContext);
00299 
00300     virtual StylesheetRoot*
00301     processStylesheet(
00302             const XSLTInputSource&          stylesheetSource,
00303             StylesheetConstructionContext&  constructionContext);
00304 
00305     virtual StylesheetRoot*
00306     processStylesheet(
00307             const XalanDOMString&           xsldocURLString,
00308             StylesheetConstructionContext&  constructionContext);
00309 
00310     virtual XalanNode*
00311     getSourceTreeFromInput(const XSLTInputSource&   inputSource);
00312 
00313     virtual void
00314     resolveTopLevelParams(StylesheetExecutionContext&   executionContext);
00315 
00316     virtual XMLParserLiaison&
00317     getXMLParserLiaison() const;
00318 
00319     virtual const XalanDOMString
00320     getUniqueNamespaceValue();
00321 
00322     virtual void
00323     getUniqueNamespaceValue(XalanDOMString&     theValue);
00324 
00325     virtual void
00326     setStylesheetParam( 
00327                     const XalanDOMString&   key,
00328                     const XalanDOMString&   expression);
00329 
00330     virtual void
00331     setStylesheetParam(
00332             const XalanDOMString&   key,
00333             XObjectPtr              value);
00334 
00335     virtual bool
00336     shouldStripSourceNode(
00337             StylesheetExecutionContext&     executionContext,
00338             const XalanNode&                node) const;
00339 
00340     virtual FormatterListener*
00341     getFormatterListener() const;
00342 
00343     virtual void
00344     setFormatterListener(FormatterListener* flistener);
00345 
00346     // Trace-related functions...
00347 
00348     virtual size_type
00349     getTraceListeners() const;
00350 
00351     virtual void
00352     addTraceListener(TraceListener*     tl);
00353 
00354     virtual void
00355     removeTraceListener(TraceListener*  tl);
00356 
00357     virtual void
00358     fireGenerateEvent(const GenerateEvent&  ge);
00359       
00360     virtual void
00361     fireTraceEvent(const TracerEvent&   te);
00362 
00363     virtual void
00364     fireSelectEvent(const SelectionEvent&   se);
00365 
00366     virtual bool
00367     getTraceSelects() const;
00368 
00369     virtual void
00370     setTraceSelects(bool    b);
00371 
00372     void
00373     traceSelect(
00374             StylesheetExecutionContext&     executionContext,
00375             const ElemTemplateElement&      theTemplate,
00376             const NodeRefListBase&          nl,
00377             const XPath*                    xpath) const;
00378 
00379     virtual void
00380     setQuietConflictWarnings(bool   b);
00381 
00382     virtual void
00383     setDiagnosticsOutput(PrintWriter*   pw);
00384 
00385 
00386     // Inherited from PrefixResolver...
00387 
00396     virtual const XalanDOMString*
00397     getNamespaceForPrefix(const XalanDOMString&     prefix) const;
00398 
00404     virtual const XalanDOMString&
00405     getURI() const;
00406 
00418     XalanDocument*
00419     parseXML(
00420             const XalanDOMString&   urlString,
00421             DocumentHandlerType*    docHandler,
00422             XalanDocument*          docToRegister);
00423 
00435     XalanDocument*
00436     parseXML(
00437             const InputSourceType&  inputSource,
00438             DocumentHandlerType*    docHandler,
00439             XalanDocument*          docToRegister);
00440 
00453     Stylesheet*
00454     getStylesheetFromPIURL(
00455             const XalanDOMString&           xslURLString,
00456             XalanNode&                      fragBase,
00457             const XalanDOMString&           xmlBaseIdent,
00458             bool                            isRoot,
00459             StylesheetConstructionContext&  constructionContext);
00460 
00464     void
00465     flushPending();
00466 
00473     void
00474     addResultNamespaceDecl(
00475             const XalanDOMString&   prefix, 
00476             const XalanDOMString&   namespaceVal)
00477     {
00478         addResultNamespaceDecl(
00479             prefix,
00480             namespaceVal.c_str(),
00481             namespaceVal.length());
00482     }
00483 
00491     void
00492     addResultNamespaceDecl(
00493             const XalanDOMString&       prefix, 
00494             const XalanDOMChar*         namespaceVal,
00495             XalanDOMString::size_type   len)
00496     {
00497         m_resultNamespacesStack.addDeclaration(
00498             prefix,
00499             namespaceVal,
00500             len);
00501     }
00502 
00511     void
00512     addResultAttribute(
00513             AttributeListImpl&      attList,
00514             const XalanDOMString&   aname,
00515             const XalanDOMString&   value)
00516     {
00517         addResultAttribute(
00518             attList,
00519             aname,
00520             value.c_str());
00521     }
00522 
00531     void
00532     addResultAttribute(
00533             AttributeListImpl&          attList,
00534             const XalanDOMString&       aname,
00535             const XalanDOMChar*         value);
00536 
00544     void
00545     addResultAttribute(
00546             const XalanDOMString&       aname,
00547             const XalanDOMChar*         value)
00548     {
00549         assert(m_outputContextStack.empty() == false);
00550 
00551         addResultAttribute(
00552                 getPendingAttributesImpl(),
00553                 aname,
00554                 value);
00555     }
00556 
00564     void
00565     addResultAttribute(
00566             const XalanDOMString&   aname,
00567             const XalanDOMString&   value)
00568     {
00569         assert(m_outputContextStack.empty() == false);
00570 
00571         addResultAttribute(
00572                 getPendingAttributesImpl(),
00573                 aname,
00574                 value);
00575     }
00576 
00577     void
00578     setDocumentLocator(const LocatorType*   locator);
00579 
00580     void
00581     startDocument();
00582 
00583     void
00584     endDocument();
00585     
00586     void
00587     startElement(
00588             const XalanDOMChar*     name,
00589             AttributeListType&      atts);
00590 
00591     void
00592     endElement(const XalanDOMChar*  name);
00593 
00594     void
00595     characters (
00596             const XalanDOMChar*         ch,
00597             XalanDOMString::size_type   length);
00598 
00599     void
00600     ignorableWhitespace(
00601             const XalanDOMChar*         ch,
00602             XalanDOMString::size_type   length);
00603 
00604     void
00605     processingInstruction(
00606             const XalanDOMChar*     target,
00607             const XalanDOMChar*     data);
00608 
00609     void
00610     resetDocument();
00611 
00619     void
00620     characters(
00621             const XalanDOMChar*         ch,
00622             XalanDOMString::size_type   start,
00623             XalanDOMString::size_type   length);
00624 
00630     void
00631     characters(const XalanNode&     node);
00632 
00638     void
00639     characters(const XObjectPtr&    xobject);
00640 
00647     void
00648     startElement(const XalanDOMChar*    name);
00649 
00659     void
00660     charactersRaw(
00661             const XalanDOMChar*         ch,
00662             XalanDOMString::size_type   start,
00663             XalanDOMString::size_type   length);
00664 
00670     void
00671     charactersRaw(const XalanNode&  node);
00672 
00678     void
00679     charactersRaw(const XObjectPtr&     xobject);
00680 
00686     void
00687     comment(const XalanDOMChar*     data);
00688 
00695     void
00696     entityReference(const XalanDOMChar*     data);
00697 
00705     void
00706     cdata(
00707             const XalanDOMChar*         ch,
00708             XalanDOMString::size_type   start,
00709             XalanDOMString::size_type   length);
00710 
00718     void
00719     cloneToResultTree(
00720             const XalanNode&    node,
00721             bool                cloneTextNodesOnly,
00722             const LocatorType*  locator);
00723 
00735     void
00736     cloneToResultTree(
00737             const XalanNode&        node,
00738             XalanNode::NodeType     nodeType,
00739             bool                    isLiteral,
00740             bool                    overrideStrip,
00741             bool                    shouldCloneAttributes,
00742             bool                    cloneTextNodesOnly,
00743             const LocatorType*      locator);
00744 
00752     void
00753     outputToResultTree(
00754             const XObject&      value,
00755             bool                outputTextNodesOnly,
00756             const LocatorType*  locator);
00757 
00766     void
00767     outputResultTreeFragment(
00768             const XObject&      theTree,
00769             bool                outputTextNodesOnly,
00770             const LocatorType*  locator)
00771     {
00772         outputResultTreeFragment(theTree.rtree(), outputTextNodesOnly, locator);
00773     }
00774 
00783     void
00784     outputResultTreeFragment(
00785             const XalanDocumentFragment&    theTree,
00786             bool                            outputTextNodesOnly,
00787             const LocatorType*              locator);
00788 
00794     virtual const StylesheetRoot*
00795     getStylesheetRoot() const;
00796 
00802     virtual void
00803     setStylesheetRoot(const StylesheetRoot*     theStylesheet);
00804 
00810     virtual void
00811     setExecutionContext(StylesheetExecutionContext*     theExecutionContext);
00812 
00819     static const XalanDOMString&
00820     getXSLNameSpaceURL()
00821     {
00822         return s_XSLNameSpaceURL;
00823     }
00824 
00830     static const XalanDOMString&
00831     getXalanXSLNameSpaceURL()
00832     {
00833         return s_XalanNamespaceURL;
00834     }
00835 
00841     bool
00842     getQuietConflictWarnings() const
00843     {
00844         return m_quietConflictWarnings;
00845     }
00846 
00847     virtual void
00848     message(
00849             const XalanDOMString&       msg,
00850             const XalanNode*            sourceNode = 0,
00851             const ElemTemplateElement*  styleNode = 0) const;
00852 
00853     virtual void
00854     message(
00855             const XalanDOMString&   msg,
00856             const LocatorType&      locator,
00857             const XalanNode*        sourceNode = 0) const;
00858 
00859     virtual void
00860     warn(
00861             const XalanDOMString&       msg,
00862             const XalanNode*            sourceNode = 0,
00863             const ElemTemplateElement*  styleNode = 0) const;
00864 
00872     virtual void
00873     warn(
00874             const char*                 msg,
00875             const XalanNode*            sourceNode = 0,
00876             const ElemTemplateElement*  styleNode = 0) const;
00877 
00878     virtual void
00879     warn(
00880             const XalanDOMString&   msg,
00881             const LocatorType&      locator,
00882             const XalanNode*        sourceNode = 0) const;
00883 
00884     virtual void
00885     error(
00886             const XalanDOMString&       msg,
00887             const XalanNode*            sourceNode = 0,
00888             const ElemTemplateElement*  styleNode = 0) const;
00889 
00890     virtual void
00891     error(
00892             const XalanDOMString&   msg,
00893             const LocatorType&      locator,
00894             const XalanNode*        sourceNode = 0) const;
00895 
00896 public:
00897 
00904     void
00905     pushTime(const void*    key);
00906 
00913     ClockType
00914     popDuration(const void*     key);
00915 
00923     void
00924     displayDuration(
00925             const XalanDOMString&   info,
00926             const void*             key);
00927 
00928 
00934     bool doDiagnosticsOutput()
00935     {
00936         return 0 != m_diagnosticsPrintWriter ? true : false;
00937     }
00938 
00944     void
00945     diag(const XalanDOMString&  s) const;
00946 
00952     void
00953     diag(const char*    s) const;
00954 
00961     const XalanDOMString*
00962     getResultNamespaceForPrefix(const XalanDOMString&   prefix) const;
00963 
00970     const XalanDOMString*
00971     getResultPrefixForNamespace(const XalanDOMString&   theNamespace) const;
00972 
00981     bool
00982     isPendingResultPrefix(const XalanDOMString&     thePrefix) const;
00983 
00992     double
00993     evalMatchPatternStr(
00994             const XalanDOMString&   str,
00995             XalanNode*              context,
00996             XPathExecutionContext&  executionContext);
00997 
01005     const XPath*
01006     createMatchPattern(
01007             const XalanDOMString&   str,
01008             const PrefixResolver&   resolver);
01009 
01016     void
01017     returnXPath(const XPath*    xpath);
01018 
01024     void
01025     copyNamespaceAttributes(const XalanNode&    src);
01026 
01034     const XObjectPtr
01035     evalXPathStr(
01036             const XalanDOMString&   str,
01037             XPathExecutionContext&  executionContext);
01038 
01048     const XObjectPtr
01049     evalXPathStr(
01050             const XalanDOMString&   str,
01051             XalanNode*              contextNode,
01052             const PrefixResolver&   prefixResolver,
01053             XPathExecutionContext&  executionContext);
01054 
01064     const XObjectPtr
01065     evalXPathStr(
01066             const XalanDOMString&   str,
01067             XalanNode*              contextNode,
01068             const XalanElement&     prefixResolver,
01069             XPathExecutionContext&  executionContext);
01070 
01078     void
01079     copyAttributeToTarget(
01080             const XalanDOMString&   attrName,
01081             const XalanDOMString&   attrValue,
01082             AttributeListImpl&      attrList);
01083 
01089     XPathFactory&
01090     getXPathFactory()
01091     {
01092         return m_xpathFactory;
01093     }
01094 
01100     XPathProcessor&
01101     getXPathProcessor()
01102     {
01103         return *m_xpathProcessor.get();
01104     }
01105 
01110     virtual void
01111     reset();
01112 
01118     XPathEnvSupport&
01119     getXPathEnvSupport()
01120     {
01121         return m_xpathEnvSupport;
01122     }
01123 
01132     void
01133     setProblemListener(ProblemListener*     l)
01134     {
01135         m_problemListener = l;
01136     }
01137 
01146     ProblemListener*
01147     getProblemListener() const
01148     {
01149         return m_problemListener;
01150     }
01151 
01152     /*
01153      * Push a new output context using the provided FormatterListener.
01154      *
01155      * @param A pointer to the FormatterListener instance for the new context.
01156      */
01157     void
01158     pushOutputContext(FormatterListener*    theListener)
01159     {
01160         m_outputContextStack.pushContext(theListener);
01161     }
01162 
01163     /*
01164      * Pop the current output context.
01165      */
01166     void
01167     popOutputContext()
01168     {
01169         m_outputContextStack.popContext();
01170     }
01171 
01172     /*
01173      * See if there is a pending start document event waiting.
01174      * @return true if there is a start document event waiting.
01175      */
01176     bool
01177     getHasPendingStartDocument() const
01178     {
01179         return getHasPendingStartDocumentImpl();
01180     }
01181 
01182     /*
01183      * Set the pending start document event state.
01184      * @param the new value
01185      */
01186     void
01187     setHasPendingStartDocument(bool b)
01188     {
01189         setHasPendingStartDocumentImpl(b);
01190     }
01191 
01192     /*
01193      * See if a pending start document event must be flushed.
01194      * @return true if the event must be flushed.
01195      */
01196     bool
01197     getMustFlushPendingStartDocument() const
01198     {
01199         return getMustFlushPendingStartDocumentImpl();
01200     }
01201 
01202     /*
01203      * Set the pending start document event flush state.
01204      * @param the new value
01205      */
01206     void
01207     setMustFlushPendingStartDocument(bool   b)
01208     {
01209         setMustFlushPendingStartDocumentImpl(b);
01210     }
01211 
01217     const AttributeListType&
01218     getPendingAttributes() const
01219     {
01220         return getPendingAttributesImpl();
01221     }
01222 
01228     void
01229     setPendingAttributes(const AttributeListType&   pendingAttributes)
01230     {
01231         getPendingAttributesImpl() = pendingAttributes;
01232     }
01233 
01241     void
01242     replacePendingAttribute(
01243             const XalanDOMChar*     theName,
01244             const XalanDOMChar*     theNewType,
01245             const XalanDOMChar*     theNewValue)
01246     {
01247         // Remove the old attribute, then add the new one.  AttributeListImpl::addAttribute()
01248         // does this for us.
01249         getPendingAttributesImpl().addAttribute(theName, theNewType, theNewValue);
01250     }
01251 
01252     bool
01253     isElementPending() const
01254     {
01255         return length(getPendingElementNameImpl()) != 0 ? true : false;
01256     }
01257 
01263     const XalanDOMString&
01264     getPendingElementName() const
01265     {
01266         return getPendingElementNameImpl();
01267     }
01268 
01274     void
01275     setPendingElementName(const XalanDOMString&     elementName)
01276     {
01277         setPendingElementNameImpl(elementName);
01278     }
01279 
01280     void
01281     setPendingElementName(const XalanDOMChar*   elementName)
01282     {
01283         setPendingElementNameImpl(elementName);
01284     }
01285 
01291     const LocatorType*
01292     getLocatorFromStack() const
01293     {
01294         return m_stylesheetLocatorStack.empty() == true ? 0 : m_stylesheetLocatorStack.back();
01295     }
01296 
01302     void
01303     pushLocatorOnStack(const LocatorType*   locator)
01304     {
01305         m_stylesheetLocatorStack.push_back(locator);
01306     }
01307 
01311     void
01312     popLocatorStack()
01313     {
01314         if (m_stylesheetLocatorStack.empty() == false)
01315         {
01316             m_stylesheetLocatorStack.pop_back();
01317         }
01318     }
01319 
01320 protected:
01321 
01327     const AttributeListImpl&
01328     getPendingAttributesImpl() const
01329     {
01330         return m_outputContextStack.getPendingAttributes();
01331     }
01332 
01338     AttributeListImpl&
01339     getPendingAttributesImpl()
01340     {
01341         return m_outputContextStack.getPendingAttributes();
01342     }
01343 
01349     void
01350     setPendingAttributesImpl(const AttributeListType&   pendingAttributes)
01351     {
01352         getPendingAttributesImpl() = pendingAttributes;
01353     }
01354 
01360     const XalanDOMString&
01361     getPendingElementNameImpl() const
01362     {
01363         return m_outputContextStack.getPendingElementName();
01364     }
01365 
01371     XalanDOMString&
01372     getPendingElementNameImpl()
01373     {
01374         return m_outputContextStack.getPendingElementName();
01375     }
01376 
01382     void
01383     setPendingElementNameImpl(const XalanDOMString&     elementName)
01384     {
01385         m_outputContextStack.getPendingElementName() = elementName;
01386     }
01387 
01393     void
01394     setPendingElementNameImpl(const XalanDOMChar*   elementName)
01395     {
01396         assert(elementName != 0);
01397 
01398         m_outputContextStack.getPendingElementName() = elementName;
01399     }
01400 
01401     /*
01402      * See if there is a pending start document event waiting.
01403      * @return true if there is a start document event waiting.
01404      */
01405     bool
01406     getHasPendingStartDocumentImpl() const
01407     {
01408         return m_outputContextStack.getHasPendingStartDocument();
01409     }
01410 
01411     /*
01412      * Set the pending start document event state.
01413      * @param the new value
01414      */
01415     void
01416     setHasPendingStartDocumentImpl(bool     b)
01417     {
01418         m_outputContextStack.getHasPendingStartDocument() = b;
01419     }
01420 
01421     /*
01422      * See if a pending start document event must be flushed.
01423      * @return true if the event must be flushed.
01424      */
01425     bool
01426     getMustFlushPendingStartDocumentImpl() const
01427     {
01428         return m_outputContextStack.getMustFlushPendingStartDocument();
01429     }
01430 
01431     /*
01432      * Set the pending start document event flush state.
01433      * @param the new value
01434      */
01435     void
01436     setMustFlushPendingStartDocumentImpl(bool   b)
01437     {
01438         m_outputContextStack.getMustFlushPendingStartDocument() = b;
01439     }
01440 
01441     FormatterListener*
01442     getFormatterListenerImpl() const
01443     {
01444         return m_outputContextStack.getFormatterListener();
01445     }
01446 
01447     void
01448     setFormatterListenerImpl(FormatterListener*     flistener)
01449     {
01450         m_outputContextStack.getFormatterListener() = flistener;
01451     }
01452 
01459     XalanDOMString  m_resultNameSpacePrefix;
01460 
01464     XalanDOMString  m_resultNameSpaceURL;
01465 
01466 
01471     void
01472     copyAttributesToAttList(
01473             const XalanNode&    node,
01474             AttributeListImpl&  attList);
01475 
01476     // Factory for creating xpaths.
01477     XPathFactory&           m_xpathFactory;
01478 
01479     // Factory for creating xobjects
01480     XObjectFactory&         m_xobjectFactory;
01481 
01482     // The query/pattern-matcher object.
01483     const XPathProcessorPtrType     m_xpathProcessor;
01484 
01489     BoolVectorType  m_cdataStack;
01490 
01491 private:
01492 
01499     void
01500     warnCopyTextNodesOnly(
01501             const XalanNode*    sourceNode,
01502             const LocatorType*  locator);
01503 
01511     void
01512     cloneToResultTree(
01513             const XalanText&    node,
01514             bool                isLiteral,
01515             bool                overrideStrip);
01516 
01521     bool
01522     pendingAttributesHasDefaultNS() const; 
01523 
01524     void
01525     addResultNamespace(
01526             const XalanDOMString&   thePrefix,
01527             const XalanDOMString&   theName,
01528             const XalanNode&        theNode,
01529             AttributeListImpl&      thePendingAttributes,
01530             bool                    fOnlyIfPrefixNotPresent);
01531 
01532     void
01533     addResultNamespace(
01534             const XalanNode&    theNode,
01535             AttributeListImpl&  thePendingAttributes,
01536             bool                fOnlyIfPrefixNotPresent = false);
01537 
01542     LocatorStack  m_stylesheetLocatorStack;
01543 
01550     ProblemListenerDefault  m_defaultProblemListener;
01551 
01552     ProblemListener*    m_problemListener;
01553 
01557     const StylesheetRoot*               m_stylesheetRoot;
01558 
01562     static const XalanDOMString&        s_XSLNameSpaceURL;  //"http://www.w3.org/1999/XSL/Transform"
01563 
01567     static const XalanDOMString&        s_XalanNamespaceURL; // "http://xml.apache.org/xalan"
01568 
01572     static const XalanDOMString&        s_uniqueNamespacePrefix;
01573 
01577     bool    m_traceSelects;
01578 
01583     bool    m_quietConflictWarnings;
01584 
01585     /*
01586      * A stream to print diagnostics to.
01587      */
01588     PrintWriter*    m_diagnosticsPrintWriter;
01589 
01590     /* For diagnostics */
01591     DurationsTableMapType   m_durationsTable;
01592 
01597     TraceListenerVectorType     m_traceListeners;
01598     
01599     void
01600     problem(
01601             const XalanDOMString&               msg, 
01602             ProblemListener::eClassification    classification,
01603             const XalanNode*                    sourceNode,
01604             const ElemTemplateElement*          styleNode) const;
01605 
01606     void
01607     problem(
01608             const XalanDOMString&               msg, 
01609             ProblemListener::eClassification    classification,
01610             const LocatorType&                  locator,
01611             const XalanNode*                    sourceNode) const;
01612 
01613   //==========================================================
01614   // SECTION: Function to do with attribute handling
01615   //==========================================================
01616 
01620     unsigned long       m_uniqueNSValue;
01621 
01622     ParamVectorType     m_topLevelParams;
01623 
01624 public:
01625 
01629     void
01630     clearTopLevelParams()
01631     {
01632         m_topLevelParams.clear();
01633     }
01634 
01635 private:
01636 
01637     bool
01638     generateCDATASection() const
01639     {
01640         if (m_hasCDATASectionElements == false)
01641         {
01642             return false;
01643         }
01644         else
01645         {
01646             assert(m_cdataStack.empty() == false);
01647 
01648             return m_cdataStack.back();
01649         }
01650     }
01651 
01652     void
01653     doFlushPending()
01654     {
01655         setMustFlushPendingStartDocument(true);
01656 
01657         flushPending();
01658     }
01659 
01667     bool
01668     isCDataResultElem(const XalanDOMString&     elementName) const;
01669 
01670     void
01671     fireCharacterGenerateEvent(
01672             const XalanNode&    theNode,
01673             bool                isCDATA);
01674 
01675     void
01676     fireCharacterGenerateEvent(
01677             const XObjectPtr&   theXObject,
01678             bool                isCDATA);
01679 
01680     void
01681     fireCharacterGenerateEvent(
01682             const XalanDOMString&   theString,
01683             bool                    isCDATA);
01684 
01685     void
01686     fireCharacterGenerateEvent(
01687             const XalanDOMChar*         ch,
01688             XalanDOMString::size_type   start,
01689             XalanDOMString::size_type   length,
01690             bool                        isCDATA);
01691 
01692     void
01693     checkDefaultNamespace(
01694             const XalanDOMString&   theElementName,
01695             const XalanDOMString&   theElementNamespaceURI);
01696 
01697     void
01698     error(
01699             const char*         theMessage,
01700             const LocatorType*  theLocator,
01701             const XalanNode*    theSourceNode);
01702 
01703     void
01704     warn(
01705             const char*         theMessage,
01706             const LocatorType*  theLocator,
01707             const XalanNode*    theSourceNode);
01708 
01709 
01710     // Data members...
01711     XMLParserLiaison&   m_parserLiaison;
01712 
01713     XPathEnvSupport&    m_xpathEnvSupport;
01714 
01715     DOMSupport&         m_domSupport;
01716 
01720     StylesheetExecutionContext*     m_executionContext;
01721 
01722     /*
01723      * Stack of current output contexts...
01724      */
01725     OutputContextStack              m_outputContextStack;
01726 
01727     /*
01728      * Stack of current result namespaces...
01729      */
01730     XalanNamespacesStack            m_resultNamespacesStack;
01731 
01732     /*
01733      * Dummy AttributeListImpl
01734      */
01735     AttributeListImpl                   m_dummyAttributesList;
01736 
01737     XalanDOMString                      m_scratchString;
01738 
01739     XalanDOMStringPointerVectorType     m_attributeNamesVisited;
01740 
01741     bool                                m_hasStripOrPreserveSpace;
01742 
01743     bool                                m_hasCDATASectionElements;
01744 
01745     XPathConstructionContextDefault     m_xpathConstructionContext;
01746 
01747     static void
01748     installFunctions();
01749 
01750     static void
01751     uninstallFunctions();
01752 
01753 
01754     static const XalanDOMString     s_emptyString;
01755 
01756     static const XalanDOMString&    s_stylesheetNodeName;
01757     static const XalanDOMString&    s_typeString;
01758     static const XalanDOMString&    s_hrefString;
01759     static const XalanDOMString&    s_piTokenizerString;
01760     static const XalanDOMString&    s_typeValueString1;
01761     static const XalanDOMString&    s_typeValueString2;
01762     static const XalanDOMString&    s_typeValueString3;
01763     static const XalanDOMString&    s_typeValueString4;
01764 
01765     // Not implemented...
01766     XSLTEngineImpl(const XSLTEngineImpl&);
01767 
01768     XSLTEngineImpl&
01769     operator=(const XSLTEngineImpl&);
01770 
01771     bool
01772     operator==(const XSLTEngineImpl&) const;
01773 };
01774 
01775 
01776 
01777 XALAN_CPP_NAMESPACE_END
01778 
01779 
01780 
01781 #endif  // XALAN_XSLTENGINEIMPL_HEADER_GUARD

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.