Xalan-C++ API Documentation

The Xalan C++ XSLT Processor Version 1.5

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-2002 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 <XalanDOM/XalanDOMString.hpp>
00082 
00083 
00084 
00085 #if defined(XALAN_AUTO_PTR_REQUIRES_DEFINITION)
00086 #include <XPath/XPathProcessor.hpp>
00087 #endif
00088 
00089 
00090 
00091 #include <Include/XalanAutoPtr.hpp>
00092 
00093 
00094 
00095 #include <PlatformSupport/AttributeListImpl.hpp>
00096 #include <PlatformSupport/DOMStringHelper.hpp>
00097 #include <PlatformSupport/PrefixResolver.hpp>
00098 
00099 
00100 
00101 #include <DOMSupport/XalanNamespacesStack.hpp>
00102 
00103 
00104 
00105 #include <XPath/Function.hpp>
00106 
00107 
00108 
00109 #include <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 ResultTreeFragBase;
00140 class StylesheetConstructionContext;
00141 class StylesheetExecutionContext;
00142 class StylesheetRoot;
00143 class XalanAttr;
00144 class XalanSourceTreeDocument;
00145 class XalanText;
00146 class XMLParserLiaison;
00147 class XObject;
00148 class XPathEnvSupport;
00149 class XPathFactory;
00150 class XPathProcessor;
00151 class XSLTResultTarget;
00152 
00153 
00154 
00167 class XALAN_XSLT_EXPORT XSLTEngineImpl : public XSLTProcessor, public PrefixResolver
00168 {
00169 public:
00170 
00171 #if defined(XALAN_STRICT_ANSI_HEADERS)
00172     typedef std::clock_t    ClockType;
00173 #else
00174     typedef clock_t         ClockType;
00175 #endif
00176 
00177     struct LessXalanDOMStringPointers
00178     {
00179         bool
00180         operator()(
00181                 const XalanDOMString*   theLHS,
00182                 const XalanDOMString*   theRHS) const
00183         {
00184             if (theLHS == 0 && theRHS != 0)
00185             {
00186                 return true;
00187             }
00188             else if (theRHS == 0)
00189             {
00190                 return false;
00191             }
00192             else
00193             {
00194                 return theLHS->compare(*theRHS) < 0 ? true : false;
00195             }
00196         }
00197     };
00198 
00199 #if defined(XALAN_NO_STD_NAMESPACE)
00200     typedef map<const void*,
00201                 ClockType,
00202                 less<const void*> >         DurationsTableMapType;
00203     typedef vector<const LocatorType*>      LocatorStack;
00204     typedef vector<TraceListener*>          TraceListenerVectorType;
00205 #if defined(XALAN_USE_DEQUE_FOR_VECTOR_BOOL)
00206     typedef deque<bool>                     BoolVectorType;
00207 #else
00208     typedef vector<bool>                    BoolVectorType;
00209 #endif
00210     typedef vector<const XalanDOMString*>   XalanDOMStringPointerVectorType;
00211 #else
00212     typedef std::map<const void*, ClockType>    DurationsTableMapType;
00213     typedef std::vector<const LocatorType*>     LocatorStack;
00214     typedef std::vector<TraceListener*>         TraceListenerVectorType;
00215 #if defined(XALAN_USE_DEQUE_FOR_VECTOR_BOOL)
00216     typedef std::deque<bool>                    BoolVectorType;
00217 #else
00218     typedef std::vector<bool>                   BoolVectorType;
00219 #endif
00220     typedef std::vector<const XalanDOMString*>  XalanDOMStringPointerVectorType;
00221 #endif
00222 
00223     struct FindStringPointerFunctor
00224     {
00225         FindStringPointerFunctor(const XalanDOMString&  theString) :
00226             m_string(theString)
00227         {
00228         }
00229 
00230         bool
00231         operator()(const XalanDOMString*    theString) const
00232         {
00233             assert(theString != 0);
00234 
00235             return *theString == m_string;
00236         }
00237 
00238     private:
00239 
00240         const XalanDOMString&   m_string;
00241     };
00242 
00243     typedef XalanAutoPtr<XPathProcessor>                XPathProcessorPtrType;
00244     typedef Function::XObjectArgVectorType              XObjectArgVectorType;
00245     typedef StylesheetExecutionContext::ParamVectorType ParamVectorType;
00246 
00247     // Public members
00248     //---------------------------------------------------------------------
00249 
00262     XSLTEngineImpl(
00263             XMLParserLiaison&   parserLiaison,
00264             XPathEnvSupport&    xpathEnvSupport,
00265             DOMSupport&         domSupport,
00266             XObjectFactory&     xobjectFactory,
00267             XPathFactory&       xpathFactory);
00268 
00269     virtual
00270     ~XSLTEngineImpl();
00271 
00276     static void
00277     initialize();
00278 
00282     static void
00283     terminate();
00284 
00285     // These methods are inherited from XSLTProcessor ...
00286     
00287     virtual void
00288     process(
00289             const XSLTInputSource&          inputSource, 
00290             const XSLTInputSource&          stylesheetSource,
00291             XSLTResultTarget&               outputTarget,
00292             StylesheetConstructionContext&  constructionContext,
00293             StylesheetExecutionContext&     executionContext);
00294 
00295     virtual void
00296     process(
00297             const XSLTInputSource&          inputSource,
00298             XSLTResultTarget&               outputTarget,
00299             StylesheetExecutionContext&     executionContext);
00300 
00301     virtual StylesheetRoot*
00302     processStylesheet(
00303             const XSLTInputSource&          stylesheetSource,
00304             StylesheetConstructionContext&  constructionContext);
00305 
00306     virtual StylesheetRoot*
00307     processStylesheet(
00308             const XalanDOMString&           xsldocURLString,
00309             StylesheetConstructionContext&  constructionContext);
00310 
00311     virtual XalanNode*
00312     getSourceTreeFromInput(const XSLTInputSource&   inputSource);
00313 
00314     virtual void
00315     resolveTopLevelParams(StylesheetExecutionContext&   executionContext);
00316 
00317     virtual XMLParserLiaison&
00318     getXMLParserLiaison() const;
00319 
00320     virtual const XalanDOMString
00321     getUniqueNamespaceValue();
00322 
00323     virtual void
00324     getUniqueNamespaceValue(XalanDOMString&     theValue);
00325 
00326     virtual void
00327     setStylesheetParam( 
00328                     const XalanDOMString&   key,
00329                     const XalanDOMString&   expression);
00330 
00331     virtual void
00332     setStylesheetParam(
00333             const XalanDOMString&   key,
00334             XObjectPtr              value);
00335 
00336     virtual bool
00337     shouldStripSourceNode(
00338             StylesheetExecutionContext&     executionContext,
00339             const XalanNode&                node) const;
00340 
00341     virtual FormatterListener*
00342     getFormatterListener() const;
00343 
00344     virtual void
00345     setFormatterListener(FormatterListener* flistener);
00346 
00347     // Trace-related functions...
00348 
00349     virtual size_type
00350     getTraceListeners() const;
00351 
00352     virtual void
00353     addTraceListener(TraceListener*     tl);
00354 
00355     virtual void
00356     removeTraceListener(TraceListener*  tl);
00357 
00358     virtual void
00359     fireGenerateEvent(const GenerateEvent&  ge);
00360       
00361     virtual void
00362     fireTraceEvent(const TracerEvent&   te);
00363 
00364     virtual void
00365     fireSelectEvent(const SelectionEvent&   se);
00366 
00367     virtual bool
00368     getTraceSelects() const;
00369 
00370     virtual void
00371     setTraceSelects(bool    b);
00372 
00373     void
00374     traceSelect(
00375             StylesheetExecutionContext&     executionContext,
00376             const ElemTemplateElement&      theTemplate,
00377             const NodeRefListBase&          nl,
00378             const XPath*                    xpath) const;
00379 
00380     virtual void
00381     setQuietConflictWarnings(bool   b);
00382 
00383     virtual void
00384     setDiagnosticsOutput(PrintWriter*   pw);
00385 
00386 
00387     // Inherited from PrefixResolver...
00388 
00397     virtual const XalanDOMString*
00398     getNamespaceForPrefix(const XalanDOMString&     prefix) const;
00399 
00405     virtual const XalanDOMString&
00406     getURI() const;
00407 
00419     XalanDocument*
00420     parseXML(
00421             const XalanDOMString&   urlString,
00422             DocumentHandlerType*    docHandler,
00423             XalanDocument*          docToRegister);
00424 
00436     XalanDocument*
00437     parseXML(
00438             const InputSourceType&  inputSource,
00439             DocumentHandlerType*    docHandler,
00440             XalanDocument*          docToRegister);
00441 
00454     Stylesheet*
00455     getStylesheetFromPIURL(
00456             const XalanDOMString&           xslURLString,
00457             XalanNode&                      fragBase,
00458             const XalanDOMString&           xmlBaseIdent,
00459             bool                            isRoot,
00460             StylesheetConstructionContext&  constructionContext);
00461 
00465     void
00466     flushPending();
00467 
00474     void
00475     addResultNamespaceDecl(
00476             const XalanDOMString&   prefix, 
00477             const XalanDOMString&   namespaceVal)
00478     {
00479         addResultNamespaceDecl(
00480             prefix,
00481             namespaceVal.c_str(),
00482             namespaceVal.length());
00483     }
00484 
00492     void
00493     addResultNamespaceDecl(
00494             const XalanDOMString&       prefix, 
00495             const XalanDOMChar*         namespaceVal,
00496             XalanDOMString::size_type   len)
00497     {
00498         m_resultNamespacesStack.addDeclaration(
00499             prefix,
00500             namespaceVal,
00501             len);
00502     }
00503 
00512     void
00513     addResultAttribute(
00514             AttributeListImpl&      attList,
00515             const XalanDOMString&   aname,
00516             const XalanDOMString&   value)
00517     {
00518         addResultAttribute(
00519             attList,
00520             aname,
00521             value.c_str());
00522     }
00523 
00532     void
00533     addResultAttribute(
00534             AttributeListImpl&          attList,
00535             const XalanDOMString&       aname,
00536             const XalanDOMChar*         value);
00537 
00545     void
00546     addResultAttribute(
00547             const XalanDOMString&       aname,
00548             const XalanDOMChar*         value)
00549     {
00550         assert(m_outputContextStack.empty() == false);
00551 
00552         addResultAttribute(
00553                 getPendingAttributesImpl(),
00554                 aname,
00555                 value);
00556     }
00557 
00565     void
00566     addResultAttribute(
00567             const XalanDOMString&   aname,
00568             const XalanDOMString&   value)
00569     {
00570         assert(m_outputContextStack.empty() == false);
00571 
00572         addResultAttribute(
00573                 getPendingAttributesImpl(),
00574                 aname,
00575                 value);
00576     }
00577 
00578     void
00579     setDocumentLocator(const LocatorType*   locator);
00580 
00581     void
00582     startDocument();
00583 
00584     void
00585     endDocument();
00586     
00587     void
00588     startElement(
00589             const XalanDOMChar*     name,
00590             AttributeListType&      atts);
00591 
00592     void
00593     endElement(const XalanDOMChar*  name);
00594 
00595     void
00596     characters (
00597             const XalanDOMChar*         ch,
00598             XalanDOMString::size_type   length);
00599 
00600     void
00601     ignorableWhitespace(
00602             const XalanDOMChar*         ch,
00603             XalanDOMString::size_type   length);
00604 
00605     void
00606     processingInstruction(
00607             const XalanDOMChar*     target,
00608             const XalanDOMChar*     data);
00609 
00610     void
00611     resetDocument();
00612 
00620     void
00621     characters(
00622             const XalanDOMChar*         ch,
00623             XalanDOMString::size_type   start,
00624             XalanDOMString::size_type   length);
00625 
00631     void
00632     characters(const XalanNode&     node);
00633 
00639     void
00640     characters(const XObjectPtr&    xobject);
00641 
00648     void
00649     startElement(const XalanDOMChar*    name);
00650 
00660     void
00661     charactersRaw(
00662             const XalanDOMChar*         ch,
00663             XalanDOMString::size_type   start,
00664             XalanDOMString::size_type   length);
00665 
00671     void
00672     charactersRaw(const XalanNode&  node);
00673 
00679     void
00680     charactersRaw(const XObjectPtr&     xobject);
00681 
00687     void
00688     comment(const XalanDOMChar*     data);
00689 
00696     void
00697     entityReference(const XalanDOMChar*     data);
00698 
00706     void
00707     cdata(
00708             const XalanDOMChar*         ch,
00709             XalanDOMString::size_type   start,
00710             XalanDOMString::size_type   length);
00711 
00719     void
00720     cloneToResultTree(
00721             const XalanNode&            node,
00722             bool                        cloneTextNodesOnly,
00723             const ElemTemplateElement*  styleNode);
00724 
00736     void
00737     cloneToResultTree(
00738             const XalanNode&            node,
00739             XalanNode::NodeType         nodeType,
00740             bool                        isLiteral,
00741             bool                        overrideStrip,
00742             bool                        shouldCloneAttributes,
00743             bool                        cloneTextNodesOnly,
00744             const ElemTemplateElement*  styleNode);
00745 
00752     void
00753     outputToResultTree(
00754             const XObject&              value,
00755             bool                        outputTextNodesOnly,
00756             const ElemTemplateElement*  styleNode);
00757 
00766     void
00767     outputResultTreeFragment(
00768             const XObject&              theTree,
00769             bool                        outputTextNodesOnly,
00770             const ElemTemplateElement*  styleNode);
00771 
00777     virtual const StylesheetRoot*
00778     getStylesheetRoot() const;
00779 
00785     virtual void
00786     setStylesheetRoot(const StylesheetRoot*     theStylesheet);
00787 
00793     virtual void
00794     setExecutionContext(StylesheetExecutionContext*     theExecutionContext);
00795 
00802     static const XalanDOMString&
00803     getXSLNameSpaceURL()
00804     {
00805         return s_XSLNameSpaceURL;
00806     }
00807 
00813     static const XalanDOMString&
00814     getXalanXSLNameSpaceURL()
00815     {
00816         return s_XalanNamespaceURL;
00817     }
00818 
00824     bool
00825     getQuietConflictWarnings() const
00826     {
00827         return m_quietConflictWarnings;
00828     }
00829 
00830     virtual void
00831     message(
00832             const XalanDOMString&       msg,
00833             const XalanNode*            sourceNode = 0,
00834             const ElemTemplateElement*  styleNode = 0) const;
00835 
00836     virtual void
00837     message(
00838             const XalanDOMString&   msg,
00839             const LocatorType&      locator,
00840             const XalanNode*        sourceNode = 0) const;
00841 
00842     virtual void
00843     warn(
00844             const XalanDOMString&       msg,
00845             const XalanNode*            sourceNode = 0,
00846             const ElemTemplateElement*  styleNode = 0) const;
00847 
00855     virtual void
00856     warn(
00857             const char*                 msg,
00858             const XalanNode*            sourceNode = 0,
00859             const ElemTemplateElement*  styleNode = 0) const;
00860 
00861     virtual void
00862     warn(
00863             const XalanDOMString&   msg,
00864             const LocatorType&      locator,
00865             const XalanNode*        sourceNode = 0) const;
00866 
00867     virtual void
00868     error(
00869             const XalanDOMString&       msg,
00870             const XalanNode*            sourceNode = 0,
00871             const ElemTemplateElement*  styleNode = 0) const;
00872 
00873     virtual void
00874     error(
00875             const XalanDOMString&   msg,
00876             const LocatorType&      locator,
00877             const XalanNode*        sourceNode = 0) const;
00878 
00879 public:
00880 
00887     void
00888     pushTime(const void*    key);
00889 
00896     ClockType
00897     popDuration(const void*     key);
00898 
00906     void
00907     displayDuration(
00908             const XalanDOMString&   info,
00909             const void*             key);
00910 
00911 
00917     bool doDiagnosticsOutput()
00918     {
00919         return 0 != m_diagnosticsPrintWriter ? true : false;
00920     }
00921 
00927     void
00928     diag(const XalanDOMString&  s) const;
00929 
00935     void
00936     diag(const char*    s) const;
00937 
00944     const XalanDOMString*
00945     getResultNamespaceForPrefix(const XalanDOMString&   prefix) const;
00946 
00953     const XalanDOMString*
00954     getResultPrefixForNamespace(const XalanDOMString&   theNamespace) const;
00955 
00964     bool
00965     isPendingResultPrefix(const XalanDOMString&     thePrefix) const;
00966 
00975     double
00976     evalMatchPatternStr(
00977             const XalanDOMString&   str,
00978             XalanNode*              context,
00979             XPathExecutionContext&  executionContext);
00980 
00988     const XPath*
00989     createMatchPattern(
00990             const XalanDOMString&   str,
00991             const PrefixResolver&   resolver);
00992 
00999     void
01000     returnXPath(const XPath*    xpath);
01001 
01007     void
01008     copyNamespaceAttributes(const XalanNode&    src);
01009 
01017     const XObjectPtr
01018     evalXPathStr(
01019             const XalanDOMString&   str,
01020             XPathExecutionContext&  executionContext);
01021 
01031     const XObjectPtr
01032     evalXPathStr(
01033             const XalanDOMString&   str,
01034             XalanNode*              contextNode,
01035             const PrefixResolver&   prefixResolver,
01036             XPathExecutionContext&  executionContext);
01037 
01047     const XObjectPtr
01048     evalXPathStr(
01049             const XalanDOMString&   str,
01050             XalanNode*              contextNode,
01051             const XalanElement&     prefixResolver,
01052             XPathExecutionContext&  executionContext);
01053 
01061     void
01062     copyAttributeToTarget(
01063             const XalanDOMString&   attrName,
01064             const XalanDOMString&   attrValue,
01065             AttributeListImpl&      attrList);
01066 
01072     XPathFactory&
01073     getXPathFactory()
01074     {
01075         return m_xpathFactory;
01076     }
01077 
01083     XPathProcessor&
01084     getXPathProcessor()
01085     {
01086         return *m_xpathProcessor.get();
01087     }
01088 
01093     virtual void
01094     reset();
01095 
01101     XPathEnvSupport&
01102     getXPathEnvSupport()
01103     {
01104         return m_xpathEnvSupport;
01105     }
01106 
01115     void
01116     setProblemListener(ProblemListener*     l)
01117     {
01118         m_problemListener = l;
01119     }
01120 
01129     ProblemListener*
01130     getProblemListener() const
01131     {
01132         return m_problemListener;
01133     }
01134 
01135     /*
01136      * Push a new output context using the provided FormatterListener.
01137      *
01138      * @param A pointer to the FormatterListener instance for the new context.
01139      */
01140     void
01141     pushOutputContext(FormatterListener*    theListener)
01142     {
01143         m_outputContextStack.pushContext(theListener);
01144     }
01145 
01146     /*
01147      * Pop the current output context.
01148      */
01149     void
01150     popOutputContext()
01151     {
01152         m_outputContextStack.popContext();
01153     }
01154 
01155     /*
01156      * See if there is a pending start document event waiting.
01157      * @return true if there is a start document event waiting.
01158      */
01159     bool
01160     getHasPendingStartDocument() const
01161     {
01162         return getHasPendingStartDocumentImpl();
01163     }
01164 
01165     /*
01166      * Set the pending start document event state.
01167      * @param the new value
01168      */
01169     void
01170     setHasPendingStartDocument(bool b)
01171     {
01172         setHasPendingStartDocumentImpl(b);
01173     }
01174 
01175     /*
01176      * See if a pending start document event must be flushed.
01177      * @return true if the event must be flushed.
01178      */
01179     bool
01180     getMustFlushPendingStartDocument() const
01181     {
01182         return getMustFlushPendingStartDocumentImpl();
01183     }
01184 
01185     /*
01186      * Set the pending start document event flush state.
01187      * @param the new value
01188      */
01189     void
01190     setMustFlushPendingStartDocument(bool   b)
01191     {
01192         setMustFlushPendingStartDocumentImpl(b);
01193     }
01194 
01200     const AttributeListType&
01201     getPendingAttributes() const
01202     {
01203         return getPendingAttributesImpl();
01204     }
01205 
01211     void
01212     setPendingAttributes(const AttributeListType&   pendingAttributes)
01213     {
01214         getPendingAttributesImpl() = pendingAttributes;
01215     }
01216 
01224     void
01225     replacePendingAttribute(
01226             const XalanDOMChar*     theName,
01227             const XalanDOMChar*     theNewType,
01228             const XalanDOMChar*     theNewValue)
01229     {
01230         // Remove the old attribute, then add the new one.  AttributeListImpl::addAttribute()
01231         // does this for us.
01232         getPendingAttributesImpl().addAttribute(theName, theNewType, theNewValue);
01233     }
01234 
01235     bool
01236     isElementPending() const
01237     {
01238         return length(getPendingElementNameImpl()) != 0 ? true : false;
01239     }
01240 
01246     const XalanDOMString&
01247     getPendingElementName() const
01248     {
01249         return getPendingElementNameImpl();
01250     }
01251 
01257     void
01258     setPendingElementName(const XalanDOMString&     elementName)
01259     {
01260         setPendingElementNameImpl(elementName);
01261     }
01262 
01263     void
01264     setPendingElementName(const XalanDOMChar*   elementName)
01265     {
01266         setPendingElementNameImpl(elementName);
01267     }
01268 
01274     const LocatorType*
01275     getLocatorFromStack() const
01276     {
01277         return m_stylesheetLocatorStack.empty() == true ? 0 : m_stylesheetLocatorStack.back();
01278     }
01279 
01285     void
01286     pushLocatorOnStack(const LocatorType*   locator)
01287     {
01288         m_stylesheetLocatorStack.push_back(locator);
01289     }
01290 
01294     void
01295     popLocatorStack()
01296     {
01297         if (m_stylesheetLocatorStack.empty() == false)
01298         {
01299             m_stylesheetLocatorStack.pop_back();
01300         }
01301     }
01302 
01303 protected:
01304 
01310     const AttributeListImpl&
01311     getPendingAttributesImpl() const
01312     {
01313         return m_outputContextStack.getPendingAttributes();
01314     }
01315 
01321     AttributeListImpl&
01322     getPendingAttributesImpl()
01323     {
01324         return m_outputContextStack.getPendingAttributes();
01325     }
01326 
01332     void
01333     setPendingAttributesImpl(const AttributeListType&   pendingAttributes)
01334     {
01335         getPendingAttributesImpl() = pendingAttributes;
01336     }
01337 
01343     const XalanDOMString&
01344     getPendingElementNameImpl() const
01345     {
01346         return m_outputContextStack.getPendingElementName();
01347     }
01348 
01354     XalanDOMString&
01355     getPendingElementNameImpl()
01356     {
01357         return m_outputContextStack.getPendingElementName();
01358     }
01359 
01365     void
01366     setPendingElementNameImpl(const XalanDOMString&     elementName)
01367     {
01368         m_outputContextStack.getPendingElementName() = elementName;
01369     }
01370 
01376     void
01377     setPendingElementNameImpl(const XalanDOMChar*   elementName)
01378     {
01379         assert(elementName != 0);
01380 
01381         m_outputContextStack.getPendingElementName() = elementName;
01382     }
01383 
01384     /*
01385      * See if there is a pending start document event waiting.
01386      * @return true if there is a start document event waiting.
01387      */
01388     bool
01389     getHasPendingStartDocumentImpl() const
01390     {
01391         return m_outputContextStack.getHasPendingStartDocument();
01392     }
01393 
01394     /*
01395      * Set the pending start document event state.
01396      * @param the new value
01397      */
01398     void
01399     setHasPendingStartDocumentImpl(bool     b)
01400     {
01401         m_outputContextStack.getHasPendingStartDocument() = b;
01402     }
01403 
01404     /*
01405      * See if a pending start document event must be flushed.
01406      * @return true if the event must be flushed.
01407      */
01408     bool
01409     getMustFlushPendingStartDocumentImpl() const
01410     {
01411         return m_outputContextStack.getMustFlushPendingStartDocument();
01412     }
01413 
01414     /*
01415      * Set the pending start document event flush state.
01416      * @param the new value
01417      */
01418     void
01419     setMustFlushPendingStartDocumentImpl(bool   b)
01420     {
01421         m_outputContextStack.getMustFlushPendingStartDocument() = b;
01422     }
01423 
01424     FormatterListener*
01425     getFormatterListenerImpl() const
01426     {
01427         return m_outputContextStack.getFormatterListener();
01428     }
01429 
01430     void
01431     setFormatterListenerImpl(FormatterListener*     flistener)
01432     {
01433         m_outputContextStack.getFormatterListener() = flistener;
01434     }
01435 
01442     XalanDOMString  m_resultNameSpacePrefix;
01443 
01447     XalanDOMString  m_resultNameSpaceURL;
01448 
01449 
01454     void
01455     copyAttributesToAttList(
01456             const XalanNode&    node,
01457             AttributeListImpl&  attList);
01458 
01459     // Factory for creating xpaths.
01460     XPathFactory&           m_xpathFactory;
01461 
01462     // Factory for creating xobjects
01463     XObjectFactory&         m_xobjectFactory;
01464 
01465     // The query/pattern-matcher object.
01466     const XPathProcessorPtrType     m_xpathProcessor;
01467 
01472     BoolVectorType  m_cdataStack;
01473 
01474 private:
01475 
01482     void
01483     warnCopyTextNodesOnly(
01484             const XalanNode*            sourceNode,
01485             const ElemTemplateElement*  styleNode) const;
01486 
01494     void
01495     cloneToResultTree(
01496             const XalanText&    node,
01497             bool                isLiteral,
01498             bool                overrideStrip);
01499 
01504     bool
01505     pendingAttributesHasDefaultNS() const; 
01506 
01507     void
01508     addResultNamespace(
01509             const XalanDOMString&   thePrefix,
01510             const XalanDOMString&   theName,
01511             const XalanNode&        theNode,
01512             AttributeListImpl&      thePendingAttributes,
01513             bool                    fOnlyIfPrefixNotPresent);
01514 
01515     void
01516     addResultNamespace(
01517             const XalanNode&    theNode,
01518             AttributeListImpl&  thePendingAttributes,
01519             bool                fOnlyIfPrefixNotPresent = false);
01520 
01525     LocatorStack  m_stylesheetLocatorStack;
01526 
01533     ProblemListenerDefault  m_defaultProblemListener;
01534 
01535     ProblemListener*    m_problemListener;
01536 
01540     const StylesheetRoot*               m_stylesheetRoot;
01541 
01545     static const XalanDOMString&        s_XSLNameSpaceURL;  //"http://www.w3.org/1999/XSL/Transform"
01546 
01550     static const XalanDOMString&        s_XalanNamespaceURL; // "http://xml.apache.org/xalan"
01551 
01555     static const XalanDOMString&        s_uniqueNamespacePrefix;
01556 
01560     bool    m_traceSelects;
01561 
01566     bool    m_quietConflictWarnings;
01567 
01568     /*
01569      * A stream to print diagnostics to.
01570      */
01571     PrintWriter*    m_diagnosticsPrintWriter;
01572 
01573     /* For diagnostics */
01574     DurationsTableMapType   m_durationsTable;
01575 
01580     TraceListenerVectorType     m_traceListeners;
01581     
01582     void
01583     problem(
01584             const XalanDOMString&               msg, 
01585             ProblemListener::eClassification    classification,
01586             const XalanNode*                    sourceNode,
01587             const ElemTemplateElement*          styleNode) const;
01588 
01589     void
01590     problem(
01591             const XalanDOMString&               msg, 
01592             ProblemListener::eClassification    classification,
01593             const LocatorType&                  locator,
01594             const XalanNode*                    sourceNode) const;
01595 
01596   //==========================================================
01597   // SECTION: Function to do with attribute handling
01598   //==========================================================
01599 
01603     unsigned long       m_uniqueNSValue;
01604 
01605     ParamVectorType     m_topLevelParams;
01606 
01607 public:
01608 
01612     void
01613     clearTopLevelParams()
01614     {
01615         m_topLevelParams.clear();
01616     }
01617 
01618 private:
01619 
01620     bool
01621     generateCDATASection() const
01622     {
01623         if (m_hasCDATASectionElements == false)
01624         {
01625             return false;
01626         }
01627         else
01628         {
01629             assert(m_cdataStack.empty() == false);
01630 
01631             return m_cdataStack.back();
01632         }
01633     }
01634 
01635     void
01636     doFlushPending()
01637     {
01638         setMustFlushPendingStartDocument(true);
01639 
01640         flushPending();
01641     }
01642 
01650     bool
01651     isCDataResultElem(const XalanDOMString&     elementName) const;
01652 
01653     void
01654     fireCharacterGenerateEvent(
01655             const XalanNode&    theNode,
01656             bool                isCDATA);
01657 
01658     void
01659     fireCharacterGenerateEvent(
01660             const XObjectPtr&   theXObject,
01661             bool                isCDATA);
01662 
01663     void
01664     fireCharacterGenerateEvent(
01665             const XalanDOMString&   theString,
01666             bool                    isCDATA);
01667 
01668     void
01669     fireCharacterGenerateEvent(
01670             const XalanDOMChar*         ch,
01671             XalanDOMString::size_type   start,
01672             XalanDOMString::size_type   length,
01673             bool                        isCDATA);
01674 
01675     void
01676     checkDefaultNamespace(
01677             const XalanDOMString&   theElementName,
01678             const XalanDOMString&   theElementNamespaceURI);
01679 
01680     XMLParserLiaison&   m_parserLiaison;
01681 
01682     XPathEnvSupport&    m_xpathEnvSupport;
01683 
01684     DOMSupport&         m_domSupport;
01685 
01689     StylesheetExecutionContext*     m_executionContext;
01690 
01691     /*
01692      * Stack of current output contexts...
01693      */
01694     OutputContextStack              m_outputContextStack;
01695 
01696     /*
01697      * Stack of current result namespaces...
01698      */
01699     XalanNamespacesStack            m_resultNamespacesStack;
01700 
01701     /*
01702      * Dummy AttributeListImpl
01703      */
01704     AttributeListImpl                   m_dummyAttributesList;
01705 
01706     XalanDOMString                      m_scratchString;
01707 
01708     XalanDOMStringPointerVectorType     m_attributeNamesVisited;
01709 
01710     bool                                m_hasStripOrPreserveSpace;
01711 
01712     bool                                m_hasCDATASectionElements;
01713 
01714     XPathConstructionContextDefault     m_xpathConstructionContext;
01715 
01716     static void
01717     installFunctions();
01718 
01719     static void
01720     uninstallFunctions();
01721 
01722 
01723     static const XalanDOMString     s_emptyString;
01724 
01725     static const XalanDOMString&    s_stylesheetNodeName;
01726     static const XalanDOMString&    s_typeString;
01727     static const XalanDOMString&    s_hrefString;
01728     static const XalanDOMString&    s_piTokenizerString;
01729     static const XalanDOMString&    s_typeValueString1;
01730     static const XalanDOMString&    s_typeValueString2;
01731     static const XalanDOMString&    s_typeValueString3;
01732     static const XalanDOMString&    s_typeValueString4;
01733 
01734     // Not implemented...
01735     XSLTEngineImpl(const XSLTEngineImpl&);
01736 
01737     XSLTEngineImpl&
01738     operator=(const XSLTEngineImpl&);
01739 
01740     bool
01741     operator==(const XSLTEngineImpl&) const;
01742 };
01743 
01744 
01745 
01746 XALAN_CPP_NAMESPACE_END
01747 
01748 
01749 
01750 #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.5
Copyright © 2000, 2001, 2002, 2003 The Apache Software Foundation. All Rights Reserved.