Xalan-C++ API Documentation

The Xalan C++ XSLT Processor Version 1.6

Main Page   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-2002 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 <xalanc/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 <xalanc/XalanDOM/XalanDOMString.hpp>
00078 
00079 
00080 
00081 XALAN_DECLARE_XERCES_CLASS(Attributes)
00082 XALAN_DECLARE_XERCES_CLASS(AttributeList)
00083 XALAN_DECLARE_XERCES_CLASS(ContentHandler)
00084 XALAN_DECLARE_XERCES_CLASS(DTDHandler)
00085 XALAN_DECLARE_XERCES_CLASS(LexicalHandler)
00086 XALAN_DECLARE_XERCES_CLASS(Locator)
00087 
00088 
00089 
00090 XALAN_CPP_NAMESPACE_BEGIN
00091 
00092 
00093 
00094 typedef XERCES_CPP_NAMESPACE_QUALIFIER Attributes       AttributesType;
00095 typedef XERCES_CPP_NAMESPACE_QUALIFIER AttributeList    AttributeListType;
00096 typedef XERCES_CPP_NAMESPACE_QUALIFIER ContentHandler   ContentHandlerType;
00097 typedef XERCES_CPP_NAMESPACE_QUALIFIER DTDHandler       DTDHandlerType;
00098 typedef XERCES_CPP_NAMESPACE_QUALIFIER LexicalHandler   LexicalHandlerType;
00099 typedef XERCES_CPP_NAMESPACE_QUALIFIER Locator          LocatorType;
00100 
00101 
00102 
00103 class XalanNode;
00104 class XalanSourceTreeDocument;
00105 class XalanSourceTreeElement;
00106 
00107 
00108 
00109 class XALAN_XALANSOURCETREE_EXPORT XalanSourceTreeContentHandler :
00110     public ContentHandlerType,
00111     public DTDHandlerType,
00112     public LexicalHandlerType
00113 {
00114 public:
00115 
00116 #if defined(XALAN_NO_STD_NAMESPACE)
00117     typedef vector<XalanSourceTreeElement*>         ElementStackType;
00118     typedef vector<XalanNode*>                      LastChildStackType;
00119 #else
00120     typedef std::vector<XalanSourceTreeElement*>    ElementStackType;
00121     typedef std::vector<XalanNode*>                 LastChildStackType;
00122 #endif
00123 
00124     enum { eDefaultStackSize = 50, eDefaultTextBufferSize = 100 };
00125 
00126 
00127     // Constructor
00128     explicit
00129     XalanSourceTreeContentHandler(
00130             XalanSourceTreeDocument*    theDocument = 0,
00131             bool                        fAccumulateText = true);
00132 
00133     virtual
00134     ~XalanSourceTreeContentHandler();
00135 
00136 
00137     // Inherited from ContentHandler...
00138     virtual void
00139     characters(
00140             const XMLCh* const  chars,
00141             const unsigned int  length);
00142 
00143     virtual void
00144     endDocument();
00145 
00146     virtual void
00147     endElement(
00148             const XMLCh* const  uri, 
00149             const XMLCh* const  localname, 
00150             const XMLCh* const  qname);
00151 
00152     virtual void
00153     ignorableWhitespace(
00154             const XMLCh* const  chars,
00155             const unsigned int  length);
00156 
00157     virtual void
00158     processingInstruction(
00159         const XMLCh* const  target,
00160         const XMLCh* const  data);
00161 
00162     virtual void
00163     setDocumentLocator(const LocatorType* const     locator);
00164 
00165     virtual void
00166     startDocument();
00167 
00168     virtual void
00169     startElement(
00170             const XMLCh* const      uri,
00171             const XMLCh* const      localname,
00172             const XMLCh* const      qname,
00173             const AttributesType&   attrs);
00174 
00175     virtual void
00176     startPrefixMapping(
00177         const XMLCh* const  prefix,
00178         const XMLCh* const  uri);
00179 
00180     virtual void
00181     endPrefixMapping(const XMLCh* const     prefix);
00182 
00183 
00184     virtual void
00185     skippedEntity(const XMLCh* const    name);
00186 
00187 
00188     // Inherited from DTDHandler...
00189 
00190     virtual void
00191     notationDecl(
00192             const XMLCh* const    name,
00193             const XMLCh* const    publicId,
00194             const XMLCh* const    systemId);
00195 
00196     virtual void
00197     unparsedEntityDecl(
00198             const XMLCh* const    name,
00199             const XMLCh* const    publicId,
00200             const XMLCh* const    systemId,
00201             const XMLCh* const    notationName);
00202 
00203     virtual void
00204     resetDocType();
00205 
00206 
00207     // Inherited from LexicalHandler...
00208 
00209     virtual void
00210     comment(
00211             const XMLCh* const  chars,
00212             const unsigned int  length);
00213 
00214     virtual void
00215     endCDATA();
00216 
00217     virtual void
00218     endDTD();
00219 
00220     virtual void
00221     endEntity(const XMLCh* const    name);
00222 
00223     virtual void
00224     startCDATA();
00225 
00226     virtual void
00227     startDTD(
00228             const XMLCh* const  name,
00229             const XMLCh* const  publicId,
00230             const XMLCh* const  systemId);
00231 
00232     virtual void
00233     startEntity(const XMLCh* const  name);
00234 
00235     
00236     // New to XalanSourceTreeContentHandler...
00237 
00238     XalanSourceTreeDocument*
00239     getDocument() const
00240     {
00241         return m_document;
00242     }
00243 
00244     void
00245     setDocument(XalanSourceTreeDocument*    theDocument);
00246 
00247 private:
00248 
00249     // Not implemented...
00250     XalanSourceTreeContentHandler(const XalanSourceTreeContentHandler&);
00251 
00252     XalanSourceTreeContentHandler&
00253     operator=(const XalanSourceTreeContentHandler&);
00254 
00255     bool
00256     operator==(const XalanSourceTreeContentHandler&) const;
00257 
00258     // Helper functions...
00259     XalanSourceTreeElement*
00260     createElement(
00261             const XMLCh* const          uri,
00262             const XMLCh* const          localname,
00263             const XMLCh* const          qname,
00264             const AttributesType&       attrs,
00265             XalanSourceTreeElement*     theOwnerElement);
00266 
00267     void
00268     processAccumulatedText();
00269 
00270     void
00271     doCharacters(
00272             const XMLCh*                chars,
00273             XalanDOMString::size_type   length);
00274 
00275     // Data members...
00276 
00277     // The current document we're building...
00278     XalanSourceTreeDocument*    m_document;
00279 
00280     // The current element...
00281     XalanSourceTreeElement*     m_currentElement;
00282 
00283     // Stack of elements...
00284     ElementStackType            m_elementStack;
00285 
00286     // The last child appended to the current element.  This is
00287     // an important optimization, because XalanSourceTreeElement
00288     // does not have a pointer to its last child.  Without this,
00289     // appending a child becomes a linear search.
00290     XalanNode*                  m_lastChild;
00291 
00292     // Stack of last children appended.  There is a ono-to-one
00293     // correspondance to the entries in m_elementStack.
00294     LastChildStackType          m_lastChildStack;
00295 
00296     // If true, the handler will accumulate text from calls to
00297     // characters() until another event triggers the creation
00298     // of the node.
00299     const bool                  m_accumulateText;
00300 
00301     // A buffer to hold accumulated text.
00302     XalanDOMString              m_textBuffer;
00303 
00304     // A flag to determine if the DTD is being processed.
00305     bool                        m_inDTD;
00306 };
00307 
00308 
00309 
00310 XALAN_CPP_NAMESPACE_END
00311 
00312 
00313 
00314 #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.6
Copyright © 2000, 2001, 2002, 2003 The Apache Software Foundation. All Rights Reserved.