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 <sax/DocumentHandler.hpp> 00071 #include <sax/DTDHandler.hpp> 00072 #include <sax2/ContentHandler.hpp> 00073 #include <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 XalanSourceTreeDocument* 00224 detachDocument(); 00225 00226 private: 00227 00228 // Not implemented... 00229 XalanSourceTreeContentHandler(const XalanSourceTreeContentHandler&); 00230 00231 XalanSourceTreeContentHandler& 00232 operator=(const XalanSourceTreeContentHandler&); 00233 00234 bool 00235 operator==(const XalanSourceTreeContentHandler&) const; 00236 00237 // Helper functions... 00238 XalanSourceTreeElement* 00239 createElement( 00240 const XMLCh* const uri, 00241 const XMLCh* const localname, 00242 const XMLCh* const qname, 00243 const Attributes& attrs, 00244 XalanSourceTreeElement* theOwnerElement); 00245 00246 void 00247 processAccumulatedText(); 00248 00249 void 00250 doCharacters( 00251 const XMLCh* chars, 00252 unsigned int length); 00253 00254 00255 // Data members... 00256 00257 // The current document we're building... 00258 XalanSourceTreeDocument* m_document; 00259 00260 // The current element... 00261 XalanSourceTreeElement* m_currentElement; 00262 00263 // Stack of elements... 00264 ElementStackType m_elementStack; 00265 00266 // The last child appended to the current element. This is 00267 // an important optimization, because XalanSourceTreeElement 00268 // does not have a pointer to it's last child. Without this, 00269 // appending a child becomes a linear search. 00270 XalanNode* m_lastChild; 00271 00272 // Stack of last children appended. There is a ono-to-one 00273 // correspondance to the entries in m_elementStack. 00274 LastChildStackType m_lastChildStack; 00275 00276 // If true, the instance owns the document and will delete 00277 // it when necessary. 00278 bool m_ownsDocument; 00279 00280 // If true, the handler will accumulate text from calls to 00281 // characters() until another event triggers the creation 00282 // of the node. 00283 const bool m_accumulateText; 00284 00285 // A buffer to hold accumulated text. 00286 XalanDOMString m_textBuffer; 00287 }; 00288 00289 00290 00291 #endif // #if !defined(XALANSOURCETREECONTENTHANDLER_HEADER_GUARD_1357924680)
Doxygen and GraphViz are used to generate this API documentation from the Xalan-C header files.
![]() |
Xalan-C++ XSL Transformer Version 1.1 |
|