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