Xalan-C++ API Documentation

The Xalan C++ XSLT Processor Version 1.4

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

FormatterToSourceTree.hpp

Go to the documentation of this file.
00001 /*
00002  * The Apache Software License, Version 1.1
00003  *
00004  *
00005  * Copyright (c) 1999-2000 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(FORMATTERTOSOURCETREE_HEADER_GUARD_1357924680)
00058 #define FORMATTERTOSOURCETREE_HEADER_GUARD_1357924680
00059 
00060 
00061 
00062 // Base include file.  Must be first.
00063 #include <XalanSourceTree/XalanSourceTreeDefinitions.hpp>
00064 
00065 
00066 
00067 #include <vector>
00068 
00069 
00070 
00071 // Base class header file.
00072 #include <PlatformSupport/FormatterListener.hpp>
00073 
00074 
00075 
00076 #include <XalanDOM/XalanDOMString.hpp>
00077 
00078 
00079 
00080 class PrefixResolver;
00081 class XalanNode;
00082 class XalanSourceTreeDocument;
00083 class XalanSourceTreeDocumentFragment;
00084 class XalanSourceTreeElement;
00085 
00086 
00087 
00092 class XALAN_XALANSOURCETREE_EXPORT FormatterToSourceTree : public FormatterListener
00093 {
00094 public:
00095 
00096 #if defined(XALAN_NO_NAMESPACES)
00097     typedef vector<XalanSourceTreeElement*>         ElementStackType;
00098     typedef vector<XalanNode*>                      LastChildStackType;
00099 #else
00100     typedef std::vector<XalanSourceTreeElement*>    ElementStackType;
00101     typedef std::vector<XalanNode*>                 LastChildStackType;
00102 #endif
00103 
00104     enum { eDefaultStackSize = 50, eDefaultTextBufferSize = 100 };
00105 
00109     static void
00110     initialize();
00111 
00115     static void
00116     terminate();
00117 
00118 
00125     explicit
00126     FormatterToSourceTree(XalanSourceTreeDocument*  theDocument = 0);
00127 
00135     FormatterToSourceTree(
00136             XalanSourceTreeDocument*            theDocument,
00137             XalanSourceTreeDocumentFragment*    theDocumentFragment);
00138 
00139     virtual
00140     ~FormatterToSourceTree();
00141 
00142 
00143     XalanSourceTreeDocument*
00144     getDocument() const
00145     {
00146         return m_document;
00147     }
00148 
00149     void
00150     setDocument(XalanSourceTreeDocument*    theDocument)
00151     {
00152         m_document = theDocument;
00153     }
00154 
00155     XalanSourceTreeDocumentFragment*
00156     getDocumentFragment() const
00157     {
00158         return m_documentFragment;
00159     }
00160 
00161     void
00162     setDocumentFragment(XalanSourceTreeDocumentFragment*    theDocumentFragment)
00163     {
00164         m_documentFragment = theDocumentFragment;
00165     }
00166 
00167     XalanSourceTreeElement*
00168     getCurrentElement() const
00169     {
00170         return m_currentElement;
00171     }
00172 
00173     void
00174     setCurrentElement(XalanSourceTreeElement*   theElement)
00175     {
00176         m_currentElement = theElement;
00177     }
00178 
00179     // These methods are inherited from DocumentHandler ...
00180 
00181     virtual void
00182     charactersRaw(
00183             const XMLCh* const  chars,
00184             const unsigned int  length);
00185 
00186     virtual void
00187     comment(const XMLCh* const  data);
00188 
00189     virtual void
00190     cdata(
00191             const XMLCh* const  ch,
00192             const unsigned int  length);
00193 
00194     virtual void
00195     entityReference(const XMLCh* const  name);
00196 
00197     virtual void
00198     setDocumentLocator(const Locator* const     locator);
00199 
00200     virtual void
00201     startDocument();
00202 
00203     virtual void
00204     endDocument();
00205 
00206     virtual void
00207     startElement(
00208                 const   XMLCh* const    name,
00209                 AttributeList&          attrs);
00210 
00211     virtual void
00212     endElement(const XMLCh* const   name);
00213 
00214     virtual void
00215     characters(
00216                 const XMLCh* const  chars,
00217                 const unsigned int  length);
00218 
00219     virtual void
00220     ignorableWhitespace(
00221                 const XMLCh* const  chars,
00222                 const unsigned int  length);
00223 
00224     virtual void
00225     processingInstruction(
00226             const XMLCh* const  target,
00227             const XMLCh* const  data);
00228 
00229     virtual void
00230     resetDocument();
00231 
00232 private:
00233 
00234     // Some utility functions...
00235     void
00236     processAccumulatedText();
00237 
00238     XalanSourceTreeElement*
00239     createElementNode(
00240             const XalanDOMChar*         name,
00241             AttributeList&              attrs,
00242             XalanSourceTreeElement*     theParentElement);
00243 
00244     void
00245     doCharacters(
00246             const XalanDOMChar*         chars,
00247             XalanDOMString::size_type   length);
00248 
00249     void
00250     doProcessingInstruction(
00251             const XalanDOMChar*     target,
00252             const XalanDOMChar*     data);
00253 
00254 
00255     // Data members...
00256     XalanSourceTreeDocument*            m_document;
00257 
00258     XalanSourceTreeDocumentFragment*    m_documentFragment;
00259 
00260     XalanSourceTreeElement*             m_currentElement;
00261 
00262     ElementStackType                    m_elementStack;
00263 
00264     // The last child appended to the current element.  This is
00265     // an important optimization, because XalanSourceTreeElement
00266     // does not have a pointer to it's last child.  Without this,
00267     // appending a child becomes a linear search.
00268     XalanNode*                          m_lastChild;
00269 
00270     // Stack of last children appended.  There is a ono-to-one
00271     // correspondance to the entries in m_elementStack.
00272     LastChildStackType                  m_lastChildStack;
00273 
00274     XalanDOMString                      m_textBuffer;
00275 };
00276 
00277 
00278 
00279 #endif  // FORMATTERTOSOURCETREE_HEADER_GUARD_1357924680

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.4
Copyright © 2000, 2001, 2002 The Apache Software Foundation. All Rights Reserved.