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 <vector> 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 public: 00053 00054 #if defined(XALAN_NO_STD_NAMESPACE) 00055 typedef vector<XalanHTMLElementsProperties::ElementProperties> ElementPropertiesStackType; 00056 #else 00057 typedef std::vector<XalanHTMLElementsProperties::ElementProperties> ElementPropertiesStackType; 00058 #endif 00059 00060 enum 00061 { 00062 eDefaultIndentAmount = 0 00063 }; 00064 00076 FormatterToHTML( 00077 Writer& writer, 00078 const XalanDOMString& encoding = XalanDOMString(), 00079 const XalanDOMString& mediaType = XalanDOMString(), 00080 const XalanDOMString& doctypeSystem = XalanDOMString(), 00081 const XalanDOMString& doctypePublic = XalanDOMString(), 00082 bool doIndent = true, 00083 int indent = eDefaultIndentAmount, 00084 bool escapeURLs = true, 00085 bool omitMetaTag = false); 00086 00087 virtual 00088 ~FormatterToHTML(); 00089 00090 // These methods are inherited from DocumentHandler ... 00091 00092 virtual void 00093 startDocument(); 00094 00095 virtual void 00096 endDocument(); 00097 00098 virtual void 00099 startElement( 00100 const XMLCh* const name, 00101 AttributeListType& attrs); 00102 00103 virtual void 00104 endElement(const XMLCh* const name); 00105 00106 virtual void 00107 characters( 00108 const XMLCh* const chars, 00109 const unsigned int length); 00110 00111 // These methods are inherited from FormatterToXML... 00112 00113 virtual bool 00114 accumDefaultEntity( 00115 XalanDOMChar ch, 00116 bool escLF); 00117 00118 // These methods are inherited from FormatterListener ... 00119 00120 virtual void 00121 entityReference(const XMLCh* const name); 00122 00123 virtual void 00124 cdata( 00125 const XMLCh* const ch, 00126 const unsigned int length); 00127 00128 virtual void 00129 processingInstruction( 00130 const XMLCh* const target, 00131 const XMLCh* const data); 00132 00133 00134 bool 00135 getEscapeURLs() const 00136 { 00137 return m_escapeURLs; 00138 } 00139 00140 void 00141 setEscapeURLs(bool flag) 00142 { 00143 m_escapeURLs = flag; 00144 } 00145 00146 struct Entity 00147 { 00148 enum { eMaxLength = 8 }; 00149 00150 XalanDOMChar m_char; 00151 00152 XalanDOMString::size_type m_length; 00153 00154 XalanDOMChar m_string[eMaxLength + 1]; 00155 }; 00156 00157 protected: 00158 00159 virtual void 00160 writeAttrString( 00161 const XalanDOMChar* theString, 00162 XalanDOMString::size_type theStringLength); 00163 00164 virtual void 00165 accumCommentData(const XalanDOMChar* data); 00166 00167 void 00168 writeCharacters(const XalanDOMString& theString); 00169 00170 void 00171 writeCharacters( 00172 const XalanDOMChar* theString, 00173 XalanDOMString::size_type theLength); 00174 00175 private: 00176 00177 typedef XalanDOMString::size_type size_type; 00178 00182 static const XalanDOMChar s_doctypeHeaderStartString[]; 00183 00184 static const size_type s_doctypeHeaderStartStringLength; 00185 00189 static const XalanDOMChar s_doctypeHeaderPublicString[]; 00190 00191 static const size_type s_doctypeHeaderPublicStringLength; 00192 00196 static const XalanDOMChar s_doctypeHeaderSystemString[]; 00197 00198 static const size_type s_doctypeHeaderSystemStringLength; 00199 00203 static const XalanDOMChar s_metaString[]; 00204 00205 static const size_type s_metaStringLength; 00206 00210 void 00211 initAttrCharsMap(); 00212 00216 void 00217 initCharsMap(); 00218 00219 void 00220 copyEntityIntoBuffer( 00221 const XalanDOMChar* s, 00222 XalanDOMString::size_type theLength); 00223 00224 void 00225 copyEntityIntoBuffer(const XalanDOMString& s); 00226 00232 virtual void 00233 processAttribute( 00234 const XalanDOMChar* name, 00235 const XalanDOMChar* value, 00236 const XalanHTMLElementsProperties::ElementProperties& elemProperties); 00237 00245 void 00246 writeAttrURI( 00247 const XalanDOMChar* theString, 00248 XalanDOMString::size_type theStringLength); 00249 00257 void 00258 accumHexNumber(XalanDOMChar theChar); 00259 00260 bool 00261 popHasNamespace(); 00262 00263 bool 00264 pushHasNamespace(const XalanDOMChar* theElementName); 00265 00266 // Data members... 00267 XalanDOMString m_currentElementName; 00268 00269 bool m_inBlockElem; 00270 00271 BoolStackType m_isRawStack; 00272 00273 bool m_isScriptOrStyleElem; 00274 00275 BoolStackType m_inScriptElemStack; 00276 00277 bool m_escapeURLs; 00278 00283 bool m_isFirstElement; 00284 00288 bool m_isUTF8; 00289 00293 int m_elementLevel; 00294 00299 BoolStackType m_hasNamespaceStack; 00300 00304 bool m_omitMetaTag; 00305 00306 ElementPropertiesStackType m_elementPropertiesStack; 00307 00308 static const XalanDOMString s_emptyString; 00309 00310 static const Entity s_entities[]; 00311 00312 static const Entity* const s_lastEntity; 00313 }; 00314 00315 00316 00317 XALAN_CPP_NAMESPACE_END 00318 00319 00320 00321 #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.8 |
|