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(FORMATTERLISTENER_HEADER_GUARD_1357924680) 00019 #define FORMATTERLISTENER_HEADER_GUARD_1357924680 00020 00021 00022 00023 // Base include file. Must be first. 00024 #include <xalanc/PlatformSupport/PlatformSupportDefinitions.hpp> 00025 00026 00027 00028 #include <xercesc/sax/DocumentHandler.hpp> 00029 00030 00031 00032 #include <xalanc/XalanDOM/XalanDOMString.hpp> 00033 00034 00035 00036 XALAN_CPP_NAMESPACE_BEGIN 00037 00038 00039 00040 class PrefixResolver; 00041 class Writer; 00042 00043 00044 00045 typedef XERCES_CPP_NAMESPACE_QUALIFIER Locator LocatorType; 00046 typedef XERCES_CPP_NAMESPACE_QUALIFIER AttributeList AttributeListType; 00047 00048 XALAN_USING_XERCES(Locator) 00049 XALAN_USING_XERCES(AttributeList) 00050 00051 00052 /** 00053 * A SAX-based formatter interface for the XSL processor. This interface 00054 * will be called as result tree elements are constructed. 00055 */ 00056 class XALAN_PLATFORMSUPPORT_EXPORT FormatterListener : public XERCES_CPP_NAMESPACE_QUALIFIER DocumentHandler 00057 { 00058 public: 00059 00060 typedef XERCES_CPP_NAMESPACE_QUALIFIER DocumentHandler ParentType; 00061 00062 // A handy typedef... Must match DocumentHandler's type for characters(), etc... 00063 typedef XalanSize_t size_type; 00064 00065 enum eFormat 00066 { 00067 OUTPUT_METHOD_NONE = 0, 00068 OUTPUT_METHOD_XML = 1, 00069 OUTPUT_METHOD_HTML = 2, 00070 OUTPUT_METHOD_TEXT = 3, 00071 OUTPUT_METHOD_DOM = 4, 00072 OUTPUT_METHOD_OTHER = 5 00073 }; 00074 00075 enum eXMLVersion 00076 { 00077 XML_VERSION_1_0 = 0, 00078 XML_VERSION_1_1 = 1 00079 }; 00080 00081 FormatterListener(eFormat theFormat); 00082 00083 virtual 00084 ~FormatterListener(); 00085 00086 /** 00087 * Get the output format for the instance. 00088 * 00089 * @return An enum indicating the output format. 00090 */ 00091 eFormat 00092 getOutputFormat() const 00093 { 00094 return m_outputFormat; 00095 } 00096 00097 /** 00098 * Get the version of XML the FormatterListener is 00099 * generating. 00100 * 00101 * @return An enum indication the XML version. 00102 */ 00103 eXMLVersion 00104 getXMLVersion() const 00105 { 00106 return m_XMLVersion; 00107 } 00108 00109 /** 00110 * Determine if the version of XML output is 1.1. 00111 * 00112 * @return true if the output version is 1.1, false if not. 00113 */ 00114 bool 00115 isXML1_1Version() const 00116 { 00117 return ( XML_VERSION_1_1 == m_XMLVersion ); 00118 } 00119 00120 /** 00121 * Get the PrefixResolver for the FormatterListener 00122 * 00123 * @return A pointer to the PrefixResolver, if any. 00124 */ 00125 const PrefixResolver* 00126 getPrefixResolver() const 00127 { 00128 return m_prefixResolver; 00129 } 00130 00131 /** 00132 * Set the PrefixResolver for the FormatterListener 00133 * 00134 * @param thePrefixResolver A pointer to the PrefixResolver, if any. 00135 */ 00136 void 00137 setPrefixResolver(const PrefixResolver* thePrefixResolver) 00138 { 00139 m_prefixResolver = thePrefixResolver; 00140 } 00141 00142 /** 00143 * Receive notification of character data. If available, when the 00144 * disable-output-escaping attribute is used, output raw text without 00145 * escaping. 00146 * 00147 * @param chars pointer to characters from the XML document 00148 * @param length number of characters to read from the array 00149 * @exception SAXException 00150 */ 00151 virtual void 00152 charactersRaw( 00153 const XMLCh* const chars, 00154 const size_type length) = 0; 00155 00156 /** 00157 * Called when a Comment is to be constructed. 00158 * 00159 * @param data pointer to comment data 00160 * @exception SAXException 00161 */ 00162 virtual void 00163 comment(const XMLCh* const data) = 0; 00164 00165 /** 00166 * Receive notification of cdata. 00167 * 00168 * <p>The Parser will call this method to report each chunk of 00169 * character data. SAX parsers may return all contiguous character 00170 * data in a single chunk, or they may split it into several 00171 * chunks; however, all of the characters in any single event 00172 * must come from the same external entity, so that the Locator 00173 * provides useful information.</p> 00174 * 00175 * <p>The application must not attempt to read from the array 00176 * outside of the specified range.</p> 00177 * 00178 * <p>Note that some parsers will report whitespace using the 00179 * ignorableWhitespace() method rather than this one (validating 00180 * parsers must do so).</p> 00181 * 00182 * @param ch pointer to characters from the XML document 00183 * @param length number of characters to read from the array 00184 * @exception SAXException 00185 */ 00186 virtual void 00187 cdata( 00188 const XMLCh* const ch, 00189 const size_type length) = 0; 00190 00191 /** 00192 * Receive notification of a entityReference. 00193 * 00194 * @param data pointer to characters from the XML document 00195 * @exception SAXException 00196 */ 00197 virtual void 00198 entityReference(const XMLCh* const name) = 0; 00199 00200 00201 // These methods are inherited from DocumentHandler ... 00202 00203 virtual void 00204 characters( 00205 const XMLCh* const chars, 00206 const size_type length) = 0; 00207 00208 virtual void 00209 endDocument() = 0; 00210 00211 virtual void 00212 endElement(const XMLCh* const name) = 0; 00213 00214 virtual void 00215 ignorableWhitespace( 00216 const XMLCh* const chars, 00217 const size_type length) = 0; 00218 00219 virtual void 00220 processingInstruction( 00221 const XMLCh* const target, 00222 const XMLCh* const data) = 0; 00223 00224 virtual void 00225 resetDocument() = 0; 00226 00227 virtual void 00228 setDocumentLocator(const Locator* const locator) = 0; 00229 00230 virtual void 00231 startDocument() = 0; 00232 00233 virtual void 00234 startElement( 00235 const XMLCh* const name, 00236 AttributeList& attrs) = 0; 00237 00238 virtual Writer* 00239 getWriter() const; 00240 00241 virtual const XalanDOMString& 00242 getDoctypeSystem() const; 00243 00244 virtual const XalanDOMString& 00245 getDoctypePublic() const; 00246 00247 virtual const XalanDOMString& 00248 getEncoding() const; 00249 00250 virtual const XalanDOMString& 00251 getMediaType() const; 00252 00253 virtual int 00254 getIndent() const; 00255 00256 00257 // Used when creating PI to work around limitations of 00258 // our interfaces... 00259 static const XalanDOMChar s_piTarget[]; 00260 00261 static const XalanDOMChar s_piData[]; 00262 00263 #if defined(XALAN_INLINE_INITIALIZATION) 00264 static const XalanDOMString::size_type s_piTargetLength = 5; 00265 static const XalanDOMString::size_type s_piDataLength = 3; 00266 #else 00267 static const XalanDOMString::size_type s_piTargetLength; 00268 static const XalanDOMString::size_type s_piDataLength; 00269 #endif 00270 00271 00272 protected: 00273 00274 // Data membmers... 00275 const PrefixResolver* m_prefixResolver; 00276 00277 static const XalanDOMString s_emptyString; 00278 00279 /** 00280 * Set the output version during serializing. 00281 * 00282 * @param theVersion XML version of the output 00283 */ 00284 void 00285 setXMLVersion(eXMLVersion theVersion) 00286 { 00287 m_XMLVersion = theVersion; 00288 } 00289 00290 private: 00291 00292 // Not implemented... 00293 FormatterListener(const FormatterListener&); 00294 00295 FormatterListener& 00296 operator=(const FormatterListener&); 00297 00298 bool 00299 operator==(const FormatterListener&) const; 00300 00301 // Data membmers... 00302 const eFormat m_outputFormat; 00303 00304 eXMLVersion m_XMLVersion; 00305 }; 00306 00307 00308 00309 XALAN_CPP_NAMESPACE_END 00310 00311 00312 00313 #endif // FORMATTERLISTENER_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 |
|