Xalan-C++ API Documentation

The Xalan C++ XSLT Processor Version 1.8

Main Page | Directories | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

XalanSourceTreeContentHandler.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 
00017 #if !defined(XALANSOURCETREECONTENTHANDLER_HEADER_GUARD_1357924680)
00018 #define XALANSOURCETREECONTENTHANDLER_HEADER_GUARD_1357924680
00019 
00020 
00021 
00022 #include <xalanc/XalanSourceTree/XalanSourceTreeDefinitions.hpp>
00023 
00024 
00025 
00026 #include <vector>
00027 
00028 
00029 
00030 #include <xercesc/sax/DocumentHandler.hpp>
00031 #include <xercesc/sax/DTDHandler.hpp>
00032 #include <xercesc/sax2/ContentHandler.hpp>
00033 #include <xercesc/sax2/LexicalHandler.hpp>
00034 
00035 
00036 
00037 #include <xalanc/XalanDOM/XalanDOMString.hpp>
00038 
00039 
00040 
00041 XALAN_DECLARE_XERCES_CLASS(Attributes)
00042 XALAN_DECLARE_XERCES_CLASS(AttributeList)
00043 XALAN_DECLARE_XERCES_CLASS(ContentHandler)
00044 XALAN_DECLARE_XERCES_CLASS(DTDHandler)
00045 XALAN_DECLARE_XERCES_CLASS(LexicalHandler)
00046 XALAN_DECLARE_XERCES_CLASS(Locator)
00047 
00048 
00049 
00050 XALAN_CPP_NAMESPACE_BEGIN
00051 
00052 
00053 
00054 typedef XERCES_CPP_NAMESPACE_QUALIFIER Attributes       AttributesType;
00055 typedef XERCES_CPP_NAMESPACE_QUALIFIER AttributeList    AttributeListType;
00056 typedef XERCES_CPP_NAMESPACE_QUALIFIER ContentHandler   ContentHandlerType;
00057 typedef XERCES_CPP_NAMESPACE_QUALIFIER DTDHandler       DTDHandlerType;
00058 typedef XERCES_CPP_NAMESPACE_QUALIFIER LexicalHandler   LexicalHandlerType;
00059 typedef XERCES_CPP_NAMESPACE_QUALIFIER Locator          LocatorType;
00060 
00061 
00062 
00063 class XalanNode;
00064 class XalanSourceTreeDocument;
00065 class XalanSourceTreeElement;
00066 
00067 
00068 
00069 class XALAN_XALANSOURCETREE_EXPORT XalanSourceTreeContentHandler :
00070     public ContentHandlerType,
00071     public DTDHandlerType,
00072     public LexicalHandlerType
00073 {
00074 public:
00075 
00076 #if defined(XALAN_NO_STD_NAMESPACE)
00077     typedef vector<XalanSourceTreeElement*>         ElementStackType;
00078     typedef vector<XalanNode*>                      LastChildStackType;
00079 #else
00080     typedef std::vector<XalanSourceTreeElement*>    ElementStackType;
00081     typedef std::vector<XalanNode*>                 LastChildStackType;
00082 #endif
00083 
00084     enum { eDefaultStackSize = 50, eDefaultTextBufferSize = 100 };
00085 
00086 
00087     // Constructor
00088     explicit
00089     XalanSourceTreeContentHandler(
00090             XalanSourceTreeDocument*    theDocument = 0,
00091             bool                        fAccumulateText = true);
00092 
00093     virtual
00094     ~XalanSourceTreeContentHandler();
00095 
00096 
00097     // Inherited from ContentHandler...
00098     virtual void
00099     characters(
00100             const XMLCh* const  chars,
00101             const unsigned int  length);
00102 
00103     virtual void
00104     endDocument();
00105 
00106     virtual void
00107     endElement(
00108             const XMLCh* const  uri, 
00109             const XMLCh* const  localname, 
00110             const XMLCh* const  qname);
00111 
00112     virtual void
00113     ignorableWhitespace(
00114             const XMLCh* const  chars,
00115             const unsigned int  length);
00116 
00117     virtual void
00118     processingInstruction(
00119         const XMLCh* const  target,
00120         const XMLCh* const  data);
00121 
00122     virtual void
00123     setDocumentLocator(const LocatorType* const     locator);
00124 
00125     virtual void
00126     startDocument();
00127 
00128     virtual void
00129     startElement(
00130             const XMLCh* const      uri,
00131             const XMLCh* const      localname,
00132             const XMLCh* const      qname,
00133             const AttributesType&   attrs);
00134 
00135     virtual void
00136     startPrefixMapping(
00137         const XMLCh* const  prefix,
00138         const XMLCh* const  uri);
00139 
00140     virtual void
00141     endPrefixMapping(const XMLCh* const     prefix);
00142 
00143 
00144     virtual void
00145     skippedEntity(const XMLCh* const    name);
00146 
00147 
00148     // Inherited from DTDHandler...
00149 
00150     virtual void
00151     notationDecl(
00152             const XMLCh* const    name,
00153             const XMLCh* const    publicId,
00154             const XMLCh* const    systemId);
00155 
00156     virtual void
00157     unparsedEntityDecl(
00158             const XMLCh* const    name,
00159             const XMLCh* const    publicId,
00160             const XMLCh* const    systemId,
00161             const XMLCh* const    notationName);
00162 
00163     virtual void
00164     resetDocType();
00165 
00166 
00167     // Inherited from LexicalHandler...
00168 
00169     virtual void
00170     comment(
00171             const XMLCh* const  chars,
00172             const unsigned int  length);
00173 
00174     virtual void
00175     endCDATA();
00176 
00177     virtual void
00178     endDTD();
00179 
00180     virtual void
00181     endEntity(const XMLCh* const    name);
00182 
00183     virtual void
00184     startCDATA();
00185 
00186     virtual void
00187     startDTD(
00188             const XMLCh* const  name,
00189             const XMLCh* const  publicId,
00190             const XMLCh* const  systemId);
00191 
00192     virtual void
00193     startEntity(const XMLCh* const  name);
00194 
00195     
00196     // New to XalanSourceTreeContentHandler...
00197 
00198     XalanSourceTreeDocument*
00199     getDocument() const
00200     {
00201         return m_document;
00202     }
00203 
00204     void
00205     setDocument(XalanSourceTreeDocument*    theDocument);
00206 
00207 private:
00208 
00209     // Not implemented...
00210     XalanSourceTreeContentHandler(const XalanSourceTreeContentHandler&);
00211 
00212     XalanSourceTreeContentHandler&
00213     operator=(const XalanSourceTreeContentHandler&);
00214 
00215     bool
00216     operator==(const XalanSourceTreeContentHandler&) const;
00217 
00218     // Helper functions...
00219     XalanSourceTreeElement*
00220     createElement(
00221             const XMLCh* const          uri,
00222             const XMLCh* const          localname,
00223             const XMLCh* const          qname,
00224             const AttributesType&       attrs,
00225             XalanSourceTreeElement*     theOwnerElement);
00226 
00227     void
00228     processAccumulatedText();
00229 
00230     void
00231     doCharacters(
00232             const XMLCh*                chars,
00233             XalanDOMString::size_type   length);
00234 
00235     // Data members...
00236 
00237     // The current document we're building...
00238     XalanSourceTreeDocument*    m_document;
00239 
00240     // The current element...
00241     XalanSourceTreeElement*     m_currentElement;
00242 
00243     // Stack of elements...
00244     ElementStackType            m_elementStack;
00245 
00246     // The last child appended to the current element.  This is
00247     // an important optimization, because XalanSourceTreeElement
00248     // does not have a pointer to its last child.  Without this,
00249     // appending a child becomes a linear search.
00250     XalanNode*                  m_lastChild;
00251 
00252     // Stack of last children appended.  There is a ono-to-one
00253     // correspondance to the entries in m_elementStack.
00254     LastChildStackType          m_lastChildStack;
00255 
00256     // If true, the handler will accumulate text from calls to
00257     // characters() until another event triggers the creation
00258     // of the node.
00259     const bool                  m_accumulateText;
00260 
00261     // A buffer to hold accumulated text.
00262     XalanDOMString              m_textBuffer;
00263 
00264     // A flag to determine if the DTD is being processed.
00265     bool                        m_inDTD;
00266 };
00267 
00268 
00269 
00270 XALAN_CPP_NAMESPACE_END
00271 
00272 
00273 
00274 #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.8
Copyright © 1999-2004 The Apache Software Foundation. All Rights Reserved.