Xalan-C++ API Documentation

The Xalan C++ XSLT Processor Version 1.10

Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

FormatterToSourceTree.hpp

Go to the documentation of this file.
00001 /*
00002  * Copyright 1999-2004 The Apache Software Foundation.
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *     http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 #if !defined(FORMATTERTOSOURCETREE_HEADER_GUARD_1357924680)
00017 #define FORMATTERTOSOURCETREE_HEADER_GUARD_1357924680
00018 
00019 
00020 
00021 // Base include file.  Must be first.
00022 #include <xalanc/XalanSourceTree/XalanSourceTreeDefinitions.hpp>
00023 
00024 
00025 
00026 #include <xalanc/Include/XalanVector.hpp>
00027 
00028 
00029 
00030 // Base class header file.
00031 #include <xalanc/PlatformSupport/FormatterListener.hpp>
00032 
00033 
00034 
00035 #include <xalanc/XalanDOM/XalanDOMString.hpp>
00036 
00037 
00038 
00039 XALAN_CPP_NAMESPACE_BEGIN
00040 
00041 
00042 
00043 class PrefixResolver;
00044 class XalanNode;
00045 class XalanSourceTreeDocument;
00046 class XalanSourceTreeDocumentFragment;
00047 class XalanSourceTreeElement;
00048 
00049 
00050 
00055 class XALAN_XALANSOURCETREE_EXPORT FormatterToSourceTree : public FormatterListener
00056 {
00057 public:
00058 
00059     typedef XalanVector<XalanSourceTreeElement*>            ElementStackType;
00060     typedef XalanVector<XalanNode*>                         LastChildStackType;
00061 
00062     enum { eDefaultStackSize = 50, eDefaultTextBufferSize = 100 };
00063 
00067     static void
00068     initialize(MemoryManagerType& theManager);
00069 
00073     static void
00074     terminate();
00075 
00076 
00083     explicit
00084     FormatterToSourceTree(  MemoryManagerType&          theManager XALAN_DEFAULT_CONSTRACTOR_MEMORY_MGR,
00085                             XalanSourceTreeDocument*    theDocument = 0);
00086 
00094     FormatterToSourceTree(
00095             XalanSourceTreeDocument*            theDocument,
00096             XalanSourceTreeDocumentFragment*    theDocumentFragment,
00097             MemoryManagerType&                  theManager XALAN_DEFAULT_MEMMGR);
00098 
00099     virtual
00100     ~FormatterToSourceTree();
00101 
00102 
00103     XalanSourceTreeDocument*
00104     getDocument() const
00105     {
00106         return m_document;
00107     }
00108 
00109     void
00110     setDocument(XalanSourceTreeDocument*    theDocument)
00111     {
00112         m_document = theDocument;
00113     }
00114 
00115     XalanSourceTreeDocumentFragment*
00116     getDocumentFragment() const
00117     {
00118         return m_documentFragment;
00119     }
00120 
00121     void
00122     setDocumentFragment(XalanSourceTreeDocumentFragment*    theDocumentFragment)
00123     {
00124         m_documentFragment = theDocumentFragment;
00125     }
00126 
00127     XalanSourceTreeElement*
00128     getCurrentElement() const
00129     {
00130         return m_currentElement;
00131     }
00132 
00133     void
00134     setCurrentElement(XalanSourceTreeElement*   theElement)
00135     {
00136         m_currentElement = theElement;
00137     }
00138 
00139     // These methods are inherited from DocumentHandler ...
00140 
00141     virtual void
00142     charactersRaw(
00143             const XMLCh* const  chars,
00144             const unsigned int  length);
00145 
00146     virtual void
00147     comment(const XMLCh* const  data);
00148 
00149     virtual void
00150     cdata(
00151             const XMLCh* const  ch,
00152             const unsigned int  length);
00153 
00154     virtual void
00155     entityReference(const XMLCh* const  name);
00156 
00157     virtual void
00158     setDocumentLocator(const LocatorType* const     locator);
00159 
00160     virtual void
00161     startDocument();
00162 
00163     virtual void
00164     endDocument();
00165 
00166     virtual void
00167     startElement(
00168                 const XMLCh* const  name,
00169                 AttributeListType&  attrs);
00170 
00171     virtual void
00172     endElement(const XMLCh* const   name);
00173 
00174     virtual void
00175     characters(
00176                 const XMLCh* const  chars,
00177                 const unsigned int  length);
00178 
00179     virtual void
00180     ignorableWhitespace(
00181                 const XMLCh* const  chars,
00182                 const unsigned int  length);
00183 
00184     virtual void
00185     processingInstruction(
00186             const XMLCh* const  target,
00187             const XMLCh* const  data);
00188 
00189     virtual void
00190     resetDocument();
00191 
00192 private:
00193 
00194     // Some utility functions...
00195     void
00196     processAccumulatedText();
00197 
00198     XalanSourceTreeElement*
00199     createElementNode(
00200             const XalanDOMChar*         name,
00201             AttributeListType&          attrs,
00202             XalanSourceTreeElement*     theParentElement);
00203 
00204     void
00205     doCharacters(
00206             const XalanDOMChar*         chars,
00207             XalanDOMString::size_type   length);
00208 
00209     void
00210     doProcessingInstruction(
00211             const XalanDOMChar*     target,
00212             const XalanDOMChar*     data);
00213 
00214 
00215     // Data members...
00216     XalanSourceTreeDocument*            m_document;
00217 
00218     XalanSourceTreeDocumentFragment*    m_documentFragment;
00219 
00220     XalanSourceTreeElement*             m_currentElement;
00221 
00222     ElementStackType                    m_elementStack;
00223 
00224     // The last child appended to the current element.  This is
00225     // an important optimization, because XalanSourceTreeElement
00226     // does not have a pointer to it's last child.  Without this,
00227     // appending a child becomes a linear search.
00228     XalanNode*                          m_lastChild;
00229 
00230     // Stack of last children appended.  There is a one-to-one
00231     // correspondance to the entries in m_elementStack.
00232     LastChildStackType                  m_lastChildStack;
00233 
00234     XalanDOMString                      m_textBuffer;
00235 };
00236 
00237 
00238 
00239 XALAN_CPP_NAMESPACE_END
00240 
00241 
00242 
00243 #endif  // FORMATTERTOSOURCETREE_HEADER_GUARD_1357924680

Interpreting class diagrams

Doxygen and GraphViz are used to generate this API documentation from the Xalan-C header files.

dot

Xalan-C++ XSLT Processor Version 1.10
Copyright © 1999-2004 The Apache Software Foundation. All Rights Reserved.

Apache Logo