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(FORMATTERTOTEXT_HEADER_GUARD_1357924680) 00019 #define FORMATTERTOTEXT_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 // Base class header file. 00033 #include <xalanc/PlatformSupport/FormatterListener.hpp> 00034 00035 00036 00037 XALAN_CPP_NAMESPACE_BEGIN 00038 00039 00040 00041 class Writer; 00042 00043 00044 00045 /** 00046 * This class takes SAX events (in addition to some extra events 00047 * that SAX doesn't handle yet) and produces simple text only. 00048 */ 00049 class XALAN_XMLSUPPORT_EXPORT FormatterToText : public FormatterListener 00050 { 00051 public: 00052 00053 /** 00054 * FormatterToText instance constructor. 00055 */ 00056 FormatterToText(MemoryManager& theManager XALAN_DEFAULT_CONSTRUCTOR_MEMMGR); 00057 00058 /** 00059 * FormatterToText instance constructor. 00060 * 00061 * @param writer writer for output 00062 * @param normalizeLindefeed Normalize \n or \r\n (on certain platforms). 00063 * @param handleIgnorableWhitespace If true ignorableWhitespace() will write data to the Writer 00064 */ 00065 FormatterToText( 00066 Writer& writer, 00067 bool normalizeLinefeed = true, 00068 bool handleIgnorableWhitespace = true, 00069 MemoryManager& theManager XALAN_DEFAULT_MEMMGR); 00070 00071 /** 00072 * FormatterToText instance constructor. 00073 * 00074 * @param writer writer for output 00075 * @param encoding character encoding for the writer 00076 * @param normalizeLindefeed Normalize \n or \r\n on certain platforms. 00077 * @param handleIgnorableWhitespace If true ignorableWhitespace() will write data to the Writer 00078 */ 00079 FormatterToText( 00080 Writer& writer, 00081 const XalanDOMString& encoding, 00082 bool normalizeLinefeed = true, 00083 bool handleIgnorableWhitespace = true, 00084 MemoryManager& theManager XALAN_DEFAULT_MEMMGR); 00085 00086 static FormatterToText* 00087 create( 00088 MemoryManager& theManager, 00089 Writer& writer, 00090 const XalanDOMString& encoding, 00091 bool normalizeLinefeed = true, 00092 bool handleIgnorableWhitespace = true); 00093 00094 virtual 00095 ~FormatterToText(); 00096 00097 MemoryManager& 00098 getMemoryManager() 00099 { 00100 return m_encoding.getMemoryManager(); 00101 } 00102 00103 Writer* 00104 getWriter() const 00105 { 00106 return m_writer; 00107 } 00108 00109 void 00110 setWriter(Writer* theWriter) 00111 { 00112 m_writer = theWriter; 00113 00114 update(false); 00115 } 00116 00117 void 00118 clearEncoding(); 00119 00120 const XalanDOMString& 00121 getEncoding() const 00122 { 00123 return m_encoding; 00124 } 00125 00126 void 00127 setEncoding(const XalanDOMString& theEncoding) 00128 { 00129 m_encoding = theEncoding; 00130 00131 update(false); 00132 } 00133 00134 XalanDOMChar 00135 getMaxCharacter() const 00136 { 00137 return m_maxCharacter; 00138 } 00139 00140 void 00141 setMaxCharacter(XalanDOMChar theMaxChar) 00142 { 00143 m_maxCharacter = theMaxChar; 00144 } 00145 00146 bool 00147 getNormalizeLinefeed() const 00148 { 00149 return m_normalize; 00150 } 00151 00152 void 00153 setNormalizeLinefeed(bool fNormalize) 00154 { 00155 m_normalize = fNormalize; 00156 } 00157 00158 bool 00159 getHandleIgnorableWhitespace() const 00160 { 00161 return m_handleIgnorableWhitespace; 00162 } 00163 00164 void 00165 setHandleIgnorableWhitespace(bool fHandle) 00166 { 00167 m_handleIgnorableWhitespace = fHandle; 00168 } 00169 00170 // These methods are inherited from FormatterListener ... 00171 00172 virtual void 00173 setDocumentLocator(const Locator* const locator); 00174 00175 virtual void 00176 startDocument(); 00177 00178 virtual void 00179 endDocument(); 00180 00181 virtual void 00182 startElement( 00183 const XMLCh* const name, 00184 AttributeListType& attrs); 00185 00186 virtual void 00187 endElement(const XMLCh* const name); 00188 00189 virtual void 00190 characters( 00191 const XMLCh* const chars, 00192 const size_type length); 00193 00194 virtual void 00195 charactersRaw( 00196 const XMLCh* const chars, 00197 const size_type length); 00198 00199 virtual void 00200 entityReference(const XMLCh* const name); 00201 00202 virtual void 00203 ignorableWhitespace( 00204 const XMLCh* const chars, 00205 const size_type length); 00206 00207 virtual void 00208 processingInstruction( 00209 const XMLCh* const target, 00210 const XMLCh* const data); 00211 00212 virtual void 00213 resetDocument(); 00214 00215 virtual void 00216 comment(const XMLCh* const data); 00217 00218 virtual void 00219 cdata( 00220 const XMLCh* const ch, 00221 const size_type length); 00222 00223 private: 00224 00225 // These are not implemented. 00226 FormatterToText(const FormatterToText&); 00227 00228 FormatterToText& 00229 operator=(const FormatterToText&); 00230 00231 bool 00232 operator==(const FormatterToText&) const; 00233 00234 // Utility function to update various member variables 00235 // when data changes. 00236 void 00237 update(bool fNormalizationOnly); 00238 00239 // Data members... 00240 Writer* m_writer; 00241 00242 XalanDOMChar m_maxCharacter; 00243 00244 XalanDOMString m_encoding; 00245 00246 bool m_haveEncoding; 00247 00248 bool m_normalize; 00249 00250 bool m_handleIgnorableWhitespace; 00251 00252 const XalanDOMChar* m_newlineString; 00253 00254 XalanDOMString::size_type m_newlineStringLength; 00255 }; 00256 00257 00258 00259 XALAN_CPP_NAMESPACE_END 00260 00261 00262 00263 #endif // FORMATTERTOTEXT_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 |
|