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 #if !defined(XMLPARSERLIAISON_HEADER_GUARD_1357924680) 00019 #define XMLPARSERLIAISON_HEADER_GUARD_1357924680 00020 00021 00022 00023 // Base include file. Must be first. 00024 #include <xalanc/XMLSupport/XMLSupportDefinitions.hpp> 00025 00026 00027 00028 #include <xalanc/XalanDOM/XalanDOMString.hpp> 00029 00030 00031 00032 XALAN_DECLARE_XERCES_CLASS(DocumentHandler) 00033 XALAN_DECLARE_XERCES_CLASS(EntityResolver) 00034 XALAN_DECLARE_XERCES_CLASS(ErrorHandler) 00035 XALAN_DECLARE_XERCES_CLASS(InputSource) 00036 XALAN_DECLARE_XERCES_CLASS(XMLEntityResolver) 00037 00038 00039 00040 XALAN_CPP_NAMESPACE_BEGIN 00041 00042 00043 00044 typedef XERCES_CPP_NAMESPACE_QUALIFIER DocumentHandler DocumentHandlerType; 00045 typedef XERCES_CPP_NAMESPACE_QUALIFIER EntityResolver EntityResolverType; 00046 typedef XERCES_CPP_NAMESPACE_QUALIFIER ErrorHandler ErrorHandlerType; 00047 typedef XERCES_CPP_NAMESPACE_QUALIFIER InputSource InputSourceType; 00048 00049 XALAN_USING_XERCES(DocumentHandler) 00050 XALAN_USING_XERCES(EntityResolver) 00051 XALAN_USING_XERCES(ErrorHandler) 00052 XALAN_USING_XERCES(InputSource) 00053 XALAN_USING_XERCES(XMLEntityResolver) 00054 00055 00056 00057 class ExecutionContext; 00058 class FormatterListener; 00059 class XalanAttr; 00060 class XalanDocument; 00061 class XalanElement; 00062 00063 00064 00065 class XALAN_XMLSUPPORT_EXPORT XMLParserLiaison 00066 { 00067 00068 public: 00069 00070 XMLParserLiaison(); 00071 00072 virtual 00073 ~XMLParserLiaison(); 00074 00075 00076 // These interfaces are new to XMLParserLiaison 00077 00078 /** 00079 * Reset the instance, freeing any XalanDocument instances created 00080 * through parseXMLStream(). 00081 */ 00082 virtual void 00083 reset() = 0; 00084 00085 /** 00086 * Get a pointer to the current ExecutionContext instance, which 00087 * may be null. 00088 * 00089 * @return A pointer to the current ExecutionContext, if any. 00090 */ 00091 virtual ExecutionContext* 00092 getExecutionContext() const = 0; 00093 00094 /** 00095 * Get a reference to the current MemoryManager instance. 00096 * 00097 * @return A pointer to the current ExecutionContext, if any. 00098 */ 00099 virtual MemoryManager& 00100 getMemoryManager() = 0; 00101 00102 /** 00103 * Set the current ExecutionContext instance. 00104 * 00105 * @parameter theContext A reference to the new ExecutionContext instance. 00106 */ 00107 virtual void 00108 setExecutionContext(ExecutionContext& theContext) = 0; 00109 00110 /** 00111 * Parse the text pointed at by the reader as XML, and return a DOM 00112 * Document interface. It is recommended that you pass in some sort of 00113 * recognizable name, such as the filename or URI, with which the reader 00114 * can be recognized if the parse fails. 00115 * 00116 * The liaison owns the XalanDocument instance, and will delete it when 00117 * asked (see DestroyDocument()), or when the liaison is reset, or goes 00118 * out of scope. 00119 * 00120 * This function is not reentrant, so you cannot call it again until 00121 * the current call exits. 00122 * 00123 * @param reader stream that should hold valid XML 00124 * @param identifier used for diagnostic purposes only, some sort of 00125 * identification for error reporting, default an empty 00126 * string 00127 * @return DOM document created 00128 */ 00129 virtual XalanDocument* 00130 parseXMLStream( 00131 const InputSource& inputSource, 00132 const XalanDOMString& identifier) = 0; 00133 00134 /** 00135 * Parse the text pointed at by the reader as XML. It is recommended that 00136 * you pass in some sort of recognizable name, such as the filename or URI, 00137 * with which the reader can be recognized if the parse fails. 00138 * 00139 * This function is reentrant, so you can call it again before any 00140 * other call exits. However, it is not thread-safe. 00141 * 00142 * @param inputSource input source that should hold valid XML 00143 * @param handler instance of a DocumentHandler 00144 * @param identifier used for diagnostic purposes only, some sort of 00145 * identification for error reporting, default an 00146 * empty string 00147 */ 00148 virtual void 00149 parseXMLStream( 00150 const InputSource& inputSource, 00151 DocumentHandler& handler, 00152 const XalanDOMString& identifier) = 0; 00153 00154 /** 00155 * Destroy the supplied XalanDocument instance. It must be an instance that 00156 * was created by a previous call to parseXMLStream(). 00157 * 00158 * @param theDocument The XalanDocument instance to destroy. 00159 */ 00160 virtual void 00161 destroyDocument(XalanDocument* theDocument) = 0; 00162 00163 /** 00164 * Get the amount to indent when indent-result="yes". 00165 * 00166 * @deprecated 00167 * 00168 * @return number of characters to indent 00169 */ 00170 virtual int 00171 getIndent() const = 0; 00172 00173 /** 00174 * Set the amount to indent when indent-result="yes". 00175 * 00176 * @deprecated 00177 * 00178 * @param i number of characters to indent 00179 */ 00180 virtual void 00181 setIndent(int i) = 0; 00182 00183 /** 00184 * Get whether or not validation will be performed. Validation is off by 00185 * default. 00186 * 00187 * @return true to perform validation 00188 */ 00189 virtual bool 00190 getUseValidation() const = 0; 00191 00192 /** 00193 * If set to true, validation will be performed. Validation is off by 00194 * default. 00195 * 00196 * @param b true to perform validation 00197 */ 00198 virtual void 00199 setUseValidation(bool b) = 0; 00200 00201 /** 00202 * Return a string suitable for telling the user what parser is being used. 00203 * 00204 * @return string describing parser 00205 */ 00206 virtual const XalanDOMString& 00207 getParserDescription(XalanDOMString& theResult) const = 0; 00208 00209 /** 00210 * This method returns the installed EntityResolver. 00211 * 00212 * @return The pointer to the installed EntityResolver object. 00213 */ 00214 virtual EntityResolver* 00215 getEntityResolver() const = 0; 00216 00217 /** 00218 * This method installs the user-specified EntityResolver on the 00219 * parser. It allows applications to trap and redirect calls to 00220 * external entities. 00221 * 00222 * A call to setEntityResolver with a non-null pointer will 00223 * uninstall any XMLEntityResolver previously installed. 00224 * 00225 * @param handler A pointer to the EntityResolver to be called 00226 * when the parser encounters references to 00227 * external entities. 00228 */ 00229 virtual void 00230 setEntityResolver(EntityResolver* resolver) = 0; 00231 00232 /** 00233 * This method returns the installed XMLEntityResolver. 00234 * 00235 * @return The pointer to the installed XMLEntityResolver object. 00236 */ 00237 virtual XMLEntityResolver* 00238 getXMLEntityResolver() const = 0; 00239 00240 /** 00241 * This method installs the user-specified XMLEntityResolver on the 00242 * parser. It allows applications to trap and redirect calls to 00243 * external entities. 00244 * 00245 * A call to setXMLEntityResolver with a non-null pointer will 00246 * uninstall any EntityResolver previously installed. 00247 * 00248 * @param handler A pointer to the entity resolver to be called 00249 * when the parser encounters references to 00250 * external entities. 00251 */ 00252 virtual void 00253 setXMLEntityResolver(XMLEntityResolver* resolver) = 0; 00254 00255 /** 00256 * This method returns the installed error handler. 00257 * 00258 * @return The pointer to the installed error handler object. 00259 */ 00260 virtual ErrorHandler* 00261 getErrorHandler() const = 0; 00262 00263 /** 00264 * This method installs the user-specified error handler. 00265 * 00266 * @param handler A pointer to the error handler to be called upon error. 00267 */ 00268 virtual void 00269 setErrorHandler(ErrorHandler* handler) = 0; 00270 00271 // A utility class for classes to use. 00272 class EnsureResetErrorHandler 00273 { 00274 public: 00275 00276 EnsureResetErrorHandler( 00277 XMLParserLiaison* theLiaison = 0, 00278 ErrorHandler* theErrorHandler = 0) : 00279 m_liaison(theLiaison), 00280 m_errorHandler(theErrorHandler) 00281 { 00282 if (theLiaison != 0) 00283 { 00284 theLiaison->setErrorHandler(theErrorHandler); 00285 } 00286 } 00287 00288 ~EnsureResetErrorHandler() 00289 { 00290 if (m_liaison != 0) 00291 { 00292 m_liaison->setErrorHandler(m_errorHandler); 00293 } 00294 } 00295 00296 void 00297 set( 00298 XMLParserLiaison* theLiaison, 00299 ErrorHandler* theErrorHandler) 00300 { 00301 m_liaison = theLiaison; 00302 00303 m_errorHandler = theErrorHandler; 00304 00305 if (theLiaison != 0) 00306 { 00307 theLiaison->setErrorHandler(theErrorHandler); 00308 } 00309 } 00310 00311 private: 00312 00313 XMLParserLiaison* m_liaison; 00314 00315 ErrorHandler* m_errorHandler; 00316 }; 00317 00318 protected: 00319 00320 // A utility class for derived classes to use. 00321 class EnsureDestroyDocument 00322 { 00323 public: 00324 00325 EnsureDestroyDocument( 00326 XMLParserLiaison& theLiaison, 00327 XalanDocument* theDocument) : 00328 m_liaison(theLiaison), 00329 m_document(theDocument) 00330 { 00331 } 00332 00333 ~EnsureDestroyDocument() 00334 { 00335 if (m_document != 0) 00336 { 00337 m_liaison.destroyDocument(m_document); 00338 } 00339 } 00340 00341 XalanDocument* 00342 get() const 00343 { 00344 return m_document; 00345 } 00346 00347 XalanDocument* 00348 release() 00349 { 00350 XalanDocument* theDocument = m_document; 00351 00352 m_document = 0; 00353 00354 return theDocument; 00355 } 00356 00357 private: 00358 00359 XMLParserLiaison& m_liaison; 00360 00361 XalanDocument* m_document; 00362 }; 00363 00364 private: 00365 00366 // Not implemented 00367 XMLParserLiaison(const XMLParserLiaison&); 00368 00369 XMLParserLiaison& 00370 operator=(const XMLParserLiaison&); 00371 }; 00372 00373 00374 00375 XALAN_CPP_NAMESPACE_END 00376 00377 00378 00379 #endif // XMLPARSERLIAISON_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 |
|