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  

XalanSourceTreeContentHandler.hpp

Go to the documentation of this file.
00001 /*
00002  * The Apache Software License, Version 1.1
00003  * 
00004  * Copyright (c) 1999-2000 The Apache Software Foundation.  All rights
00005  * reserved.
00006  * 
00007  * Redistribution and use in source and binary forms, with or without
00008  * modification, are permitted provided that the following conditions
00009  * are met:
00010  * 
00011  * 1. Redistributions of source code must retain the above copyright
00012  *    notice, this list of conditions and the following disclaimer. 
00013  * 
00014  * 2. Redistributions in binary form must reproduce the above copyright
00015  *    notice, this list of conditions and the following disclaimer in
00016  *    the documentation and/or other materials provided with the
00017  *    distribution.
00018  * 
00019  * 3. The end-user documentation included with the redistribution,
00020  *    if any, must include the following acknowledgment:  
00021  *       "This product includes software developed by the
00022  *        Apache Software Foundation (http://www.apache.org/)."
00023  *    Alternately, this acknowledgment may appear in the software itself,
00024  *    if and wherever such third-party acknowledgments normally appear.
00025  * 
00026  * 4. The names "Xerces" and "Apache Software Foundation" must
00027  *    not be used to endorse or promote products derived from this
00028  *    software without prior written permission. For written 
00029  *    permission, please contact apache\@apache.org.
00030  * 
00031  * 5. Products derived from this software may not be called "Apache",
00032  *    nor may "Apache" appear in their name, without prior written
00033  *    permission of the Apache Software Foundation.
00034  * 
00035  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
00036  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00037  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00038  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
00039  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00040  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00041  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
00042  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00043  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00044  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
00045  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00046  * SUCH DAMAGE.
00047  * ====================================================================
00048  * 
00049  * This software consists of voluntary contributions made by many
00050  * individuals on behalf of the Apache Software Foundation, and was
00051  * originally based on software copyright (c) 1999, International
00052  * Business Machines, Inc., http://www.ibm.com .  For more information
00053  * on the Apache Software Foundation, please see
00054  * <http://www.apache.org/>.
00055  */
00056 
00057 #if !defined(XALANSOURCETREECONTENTHANDLER_HEADER_GUARD_1357924680)
00058 #define XALANSOURCETREECONTENTHANDLER_HEADER_GUARD_1357924680
00059 
00060 
00061 
00062 #include <XalanSourceTree/XalanSourceTreeDefinitions.hpp>
00063 
00064 
00065 
00066 #include <vector>
00067 
00068 
00069 
00070 #include <xercesc/sax/DocumentHandler.hpp>
00071 #include <xercesc/sax/DTDHandler.hpp>
00072 #include <xercesc/sax2/ContentHandler.hpp>
00073 #include <xercesc/sax2/LexicalHandler.hpp>
00074 
00075 
00076 
00077 #include <XalanDOM/XalanDOMString.hpp>
00078 
00079 
00080 
00081 class XalanNode;
00082 class XalanSourceTreeDocument;
00083 class XalanSourceTreeElement;
00084 
00085 
00086 
00087 class XALAN_XALANSOURCETREE_EXPORT XalanSourceTreeContentHandler : public ContentHandler, public DTDHandler, public LexicalHandler
00088 {
00089 public:
00091 
00092 #if defined(XALAN_NO_NAMESPACES)
00093     typedef vector<XalanSourceTreeElement*>         ElementStackType;
00094     typedef vector<XalanNode*>                      LastChildStackType;
00095 #else
00096     typedef std::vector<XalanSourceTreeElement*>    ElementStackType;
00097     typedef std::vector<XalanNode*>                 LastChildStackType;
00098 #endif
00099 
00100     enum { eDefaultStackSize = 50, eDefaultTextBufferSize = 100 };
00101 
00102 
00103     // Constructor
00104     explicit
00105     XalanSourceTreeContentHandler(
00106             XalanSourceTreeDocument*    theDocument = 0,
00107             bool                        fAccumulateText = true);
00108 
00109     virtual
00110     ~XalanSourceTreeContentHandler();
00111 
00112 
00113     // Inherited from ContentHandler...
00114     virtual void
00115     characters(
00116             const XMLCh* const  chars,
00117             const unsigned int  length);
00118 
00119     virtual void
00120     endDocument();
00121 
00122     virtual void
00123     endElement(
00124             const XMLCh* const  uri, 
00125             const XMLCh* const  localname, 
00126             const XMLCh* const  qname);
00127 
00128     virtual void
00129     ignorableWhitespace(
00130             const XMLCh* const  chars,
00131             const unsigned int  length);
00132 
00133     virtual void
00134     processingInstruction(
00135         const XMLCh* const  target,
00136         const XMLCh* const  data);
00137 
00138     virtual void
00139     setDocumentLocator(const Locator* const     locator);
00140 
00141     virtual void
00142     startDocument();
00143 
00144     virtual void
00145     startElement(
00146             const XMLCh* const  uri,
00147             const XMLCh* const  localname,
00148             const XMLCh* const  qname,
00149             const Attributes&   attrs);
00150 
00151     virtual void
00152     startPrefixMapping(
00153         const XMLCh* const  prefix,
00154         const XMLCh* const  uri);
00155 
00156     virtual void
00157     endPrefixMapping(const XMLCh* const     prefix);
00158 
00159 
00160     virtual void
00161     skippedEntity(const XMLCh* const    name);
00162 
00163 
00164     // Inherited from DTDHandler...
00165 
00166     virtual void
00167     notationDecl(
00168             const XMLCh* const    name,
00169             const XMLCh* const    publicId,
00170             const XMLCh* const    systemId);
00171 
00172     virtual void
00173     unparsedEntityDecl(
00174             const XMLCh* const    name,
00175             const XMLCh* const    publicId,
00176             const XMLCh* const    systemId,
00177             const XMLCh* const    notationName);
00178 
00179     virtual void
00180     resetDocType();
00181 
00182 
00183     // Inherited from LexicalHandler...
00184 
00185     virtual void
00186     comment(
00187             const XMLCh* const  chars,
00188             const unsigned int  length);
00189 
00190     virtual void
00191     endCDATA();
00192 
00193     virtual void
00194     endDTD();
00195 
00196     virtual void
00197     endEntity(const XMLCh* const    name);
00198 
00199     virtual void
00200     startCDATA();
00201 
00202     virtual void
00203     startDTD(
00204             const XMLCh* const  name,
00205             const XMLCh* const  publicId,
00206             const XMLCh* const  systemId);
00207 
00208     virtual void
00209     startEntity(const XMLCh* const  name);
00210 
00211     
00212     // New to XalanSourceTreeContentHandler...
00213 
00214     XalanSourceTreeDocument*
00215     getDocument() const
00216     {
00217         return m_document;
00218     }
00219 
00220     void
00221     setDocument(XalanSourceTreeDocument*    theDocument);
00222 
00223 private:
00224 
00225     // Not implemented...
00226     XalanSourceTreeContentHandler(const XalanSourceTreeContentHandler&);
00227 
00228     XalanSourceTreeContentHandler&
00229     operator=(const XalanSourceTreeContentHandler&);
00230 
00231     bool
00232     operator==(const XalanSourceTreeContentHandler&) const;
00233 
00234     // Helper functions...
00235     XalanSourceTreeElement*
00236     createElement(
00237             const XMLCh* const          uri,
00238             const XMLCh* const          localname,
00239             const XMLCh* const          qname,
00240             const Attributes&           attrs,
00241             XalanSourceTreeElement*     theOwnerElement);
00242 
00243     void
00244     processAccumulatedText();
00245 
00246     void
00247     doCharacters(
00248             const XMLCh*    chars,
00249             unsigned int    length);
00250 
00251 
00252     // Data members...
00253 
00254     // The current document we're building...
00255     XalanSourceTreeDocument*    m_document;
00256 
00257     // The current element...
00258     XalanSourceTreeElement*     m_currentElement;
00259 
00260     // Stack of elements...
00261     ElementStackType            m_elementStack;
00262 
00263     // The last child appended to the current element.  This is
00264     // an important optimization, because XalanSourceTreeElement
00265     // does not have a pointer to it's last child.  Without this,
00266     // appending a child becomes a linear search.
00267     XalanNode*                  m_lastChild;
00268 
00269     // Stack of last children appended.  There is a ono-to-one
00270     // correspondance to the entries in m_elementStack.
00271     LastChildStackType          m_lastChildStack;
00272 
00273     // If true, the handler will accumulate text from calls to
00274     // characters() until another event triggers the creation
00275     // of the node.
00276     const bool                  m_accumulateText;
00277 
00278     // A buffer to hold accumulated text.
00279     XalanDOMString              m_textBuffer;
00280 
00281     // A flag to determine if the DTD is being processed.
00282     bool                        m_inDTD;
00283 };
00284 
00285 
00286 
00287 #endif  // #if !defined(XALANSOURCETREECONTENTHANDLER_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.