00001 /* 00002 * Copyright 1999-2004 The Apache Software Foundation. 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 #if !defined(FORMATTERTOHTML_HEADER_GUARD_1357924680) 00017 #define FORMATTERTOHTML_HEADER_GUARD_1357924680 00018 00019 00020 00021 // Base include file. Must be first. 00022 #include <xalanc/XMLSupport/XMLSupportDefinitions.hpp> 00023 00024 00025 00026 #include <xalanc/Include/XalanVector.hpp> 00027 00028 00029 00030 // Base class header file. 00031 #include <xalanc/XMLSupport/FormatterToXML.hpp> 00032 00033 00034 00035 #include <xalanc/PlatformSupport/DOMStringHelper.hpp> 00036 00037 00038 00039 #include <xalanc/XMLSupport/XalanHTMLElementsProperties.hpp> 00040 00041 00042 00043 XALAN_CPP_NAMESPACE_BEGIN 00044 00045 00046 00050 class XALAN_XMLSUPPORT_EXPORT FormatterToHTML : public FormatterToXML 00051 { 00052 00053 public: 00054 00055 00056 typedef XalanVector<XalanHTMLElementsProperties::ElementProperties> ElementPropertiesStackType; 00057 00058 00059 enum 00060 { 00061 eDefaultIndentAmount = 0 00062 }; 00063 00075 FormatterToHTML( 00076 Writer& writer, 00077 const XalanDOMString& encoding = XalanDOMString(XalanMemMgrs::getDummyMemMgr()), 00078 const XalanDOMString& mediaType = XalanDOMString(XalanMemMgrs::getDummyMemMgr()), 00079 const XalanDOMString& doctypeSystem = XalanDOMString(XalanMemMgrs::getDummyMemMgr()), 00080 const XalanDOMString& doctypePublic = XalanDOMString(XalanMemMgrs::getDummyMemMgr()), 00081 bool doIndent = true, 00082 int indent = eDefaultIndentAmount, 00083 bool escapeURLs = true, 00084 bool omitMetaTag = false, 00085 MemoryManagerType& theManager XALAN_DEFAULT_MEMMGR); 00086 00087 static FormatterToHTML* 00088 create( 00089 MemoryManagerType& theManager, 00090 Writer& writer, 00091 const XalanDOMString& encoding, 00092 const XalanDOMString& mediaType, 00093 const XalanDOMString& doctypeSystem, 00094 const XalanDOMString& doctypePublic, 00095 bool doIndent, 00096 int indent, 00097 bool escapeURLs, 00098 bool omitMetaTag); 00099 virtual 00100 ~FormatterToHTML(); 00101 00102 // These methods are inherited from DocumentHandler ... 00103 00104 virtual void 00105 startDocument(); 00106 00107 virtual void 00108 endDocument(); 00109 00110 virtual void 00111 startElement( 00112 const XMLCh* const name, 00113 AttributeListType& attrs); 00114 00115 virtual void 00116 endElement(const XMLCh* const name); 00117 00118 virtual void 00119 characters( 00120 const XMLCh* const chars, 00121 const unsigned int length); 00122 00123 // These methods are inherited from FormatterToXML... 00124 00125 virtual bool 00126 accumDefaultEntity( 00127 XalanDOMChar ch, 00128 bool escLF); 00129 00130 // These methods are inherited from FormatterListener ... 00131 00132 virtual void 00133 entityReference(const XMLCh* const name); 00134 00135 virtual void 00136 cdata( 00137 const XMLCh* const ch, 00138 const unsigned int length); 00139 00140 virtual void 00141 processingInstruction( 00142 const XMLCh* const target, 00143 const XMLCh* const data); 00144 00145 00146 bool 00147 getEscapeURLs() const 00148 { 00149 return m_escapeURLs; 00150 } 00151 00152 void 00153 setEscapeURLs(bool flag) 00154 { 00155 m_escapeURLs = flag; 00156 } 00157 00158 struct Entity 00159 { 00160 enum { eMaxLength = 8 }; 00161 00162 XalanDOMChar m_char; 00163 00164 XalanDOMString::size_type m_length; 00165 00166 XalanDOMChar m_string[eMaxLength + 1]; 00167 }; 00168 00169 protected: 00170 00171 virtual void 00172 writeAttrString( 00173 const XalanDOMChar* theString, 00174 XalanDOMString::size_type theStringLength); 00175 00176 virtual void 00177 accumCommentData(const XalanDOMChar* data); 00178 00179 void 00180 writeCharacters(const XalanDOMString& theString); 00181 00182 void 00183 writeCharacters( 00184 const XalanDOMChar* theString, 00185 XalanDOMString::size_type theLength); 00186 00187 private: 00188 00189 typedef XalanDOMString::size_type size_type; 00190 00194 static const XalanDOMChar s_doctypeHeaderStartString[]; 00195 00196 static const size_type s_doctypeHeaderStartStringLength; 00197 00201 static const XalanDOMChar s_doctypeHeaderPublicString[]; 00202 00203 static const size_type s_doctypeHeaderPublicStringLength; 00204 00208 static const XalanDOMChar s_doctypeHeaderSystemString[]; 00209 00210 static const size_type s_doctypeHeaderSystemStringLength; 00211 00215 static const XalanDOMChar s_metaString[]; 00216 00217 static const size_type s_metaStringLength; 00218 00222 void 00223 initAttrCharsMap(); 00224 00228 void 00229 initCharsMap(); 00230 00231 void 00232 copyEntityIntoBuffer( 00233 const XalanDOMChar* s, 00234 XalanDOMString::size_type theLength); 00235 00236 void 00237 copyEntityIntoBuffer(const XalanDOMString& s); 00238 00244 virtual void 00245 processAttribute( 00246 const XalanDOMChar* name, 00247 const XalanDOMChar* value, 00248 const XalanHTMLElementsProperties::ElementProperties& elemProperties); 00249 00257 void 00258 writeAttrURI( 00259 const XalanDOMChar* theString, 00260 XalanDOMString::size_type theStringLength); 00261 00269 void 00270 accumHexNumber(XalanDOMChar theChar); 00271 00272 bool 00273 popHasNamespace(); 00274 00275 bool 00276 pushHasNamespace(const XalanDOMChar* theElementName); 00277 00278 // Data members... 00279 XalanDOMString m_currentElementName; 00280 00281 bool m_inBlockElem; 00282 00283 BoolStackType m_isRawStack; 00284 00285 bool m_isScriptOrStyleElem; 00286 00287 BoolStackType m_inScriptElemStack; 00288 00289 bool m_escapeURLs; 00290 00295 bool m_isFirstElement; 00296 00300 bool m_isUTF8; 00301 00305 int m_elementLevel; 00306 00311 BoolStackType m_hasNamespaceStack; 00312 00316 bool m_omitMetaTag; 00317 00318 ElementPropertiesStackType m_elementPropertiesStack; 00319 00320 static const XalanDOMString s_emptyString; 00321 00322 static const Entity s_entities[]; 00323 00324 static const Entity* const s_lastEntity; 00325 }; 00326 00327 00328 00329 XALAN_CPP_NAMESPACE_END 00330 00331 00332 00333 #endif // FORMATTERTOHTML_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.10 |
|