00001 /* 00002 * The Apache Software License, Version 1.1 00003 * 00004 * 00005 * Copyright (c) 1999 The Apache Software Foundation. All rights 00006 * reserved. 00007 * 00008 * Redistribution and use in source and binary forms, with or without 00009 * modification, are permitted provided that the following conditions 00010 * are met: 00011 * 00012 * 1. Redistributions of source code must retain the above copyright 00013 * notice, this list of conditions and the following disclaimer. 00014 * 00015 * 2. Redistributions in binary form must reproduce the above copyright 00016 * notice, this list of conditions and the following disclaimer in 00017 * the documentation and/or other materials provided with the 00018 * distribution. 00019 * 00020 * 3. The end-user documentation included with the redistribution, 00021 * if any, must include the following acknowledgment: 00022 * "This product includes software developed by the 00023 * Apache Software Foundation (http://www.apache.org/)." 00024 * Alternately, this acknowledgment may appear in the software itself, 00025 * if and wherever such third-party acknowledgments normally appear. 00026 * 00027 * 4. The names "Xalan" and "Apache Software Foundation" must 00028 * not be used to endorse or promote products derived from this 00029 * software without prior written permission. For written 00030 * permission, please contact apache@apache.org. 00031 * 00032 * 5. Products derived from this software may not be called "Apache", 00033 * nor may "Apache" appear in their name, without prior written 00034 * permission of the Apache Software Foundation. 00035 * 00036 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 00037 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00038 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00039 * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR 00040 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00041 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00042 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 00043 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 00044 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00045 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 00046 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 00047 * SUCH DAMAGE. 00048 * ==================================================================== 00049 * 00050 * This software consists of voluntary contributions made by many 00051 * individuals on behalf of the Apache Software Foundation and was 00052 * originally based on software copyright (c) 1999, International 00053 * Business Machines, Inc., http://www.ibm.com. For more 00054 * information on the Apache Software Foundation, please see 00055 * <http://www.apache.org/>. 00056 */ 00057 #if !defined(FORMATTERTOHTML_HEADER_GUARD_1357924680) 00058 #define FORMATTERTOHTML_HEADER_GUARD_1357924680 00059 00067 00068 00069 00070 // Base include file. Must be first. 00071 #include <XMLSupport/XMLSupportDefinitions.hpp> 00072 00073 00074 00075 #include <set> 00076 #include <map> 00077 #include <vector> 00078 00079 00080 00081 // Base class header file. 00082 #include <XMLSupport/FormatterToXML.hpp> 00083 00084 00085 00086 #include <Include/XalanArrayKeyMap.hpp> 00087 00088 00089 00090 #include <PlatformSupport/DOMStringHelper.hpp> 00091 00092 00093 00094 class PrefixResolver; 00095 00096 00097 00101 class XALAN_XMLSUPPORT_EXPORT FormatterToHTML : public FormatterToXML 00102 { 00103 00104 public: 00105 00106 #if defined(XALAN_NO_NAMESPACES) 00107 typedef map<XalanDOMChar, 00108 XalanDOMString, 00109 less<XalanDOMChar> > XalanEntityReferenceType; 00110 #else 00111 typedef std::map<XalanDOMChar, 00112 XalanDOMString> XalanEntityReferenceType; 00113 #endif 00114 00118 static void 00119 initialize(); 00120 00124 static void 00125 terminate(); 00126 00127 enum eDummy 00128 { 00129 eDefaultIndentAmount = 0 00130 }; 00131 00139 FormatterToHTML( 00140 Writer& writer, 00141 const XalanDOMString& encoding = XalanDOMString(), 00142 const XalanDOMString& mediaType = XalanDOMString(), 00143 const XalanDOMString& doctypeSystem = XalanDOMString(), 00144 const XalanDOMString& doctypePublic = XalanDOMString(), 00145 bool doIndent = true, 00146 int indent = eDefaultIndentAmount, 00147 const XalanDOMString& version = XalanDOMString(), 00148 const XalanDOMString& standalone = XalanDOMString(), 00149 bool xmlDecl = false); 00150 00151 virtual 00152 ~FormatterToHTML(); 00153 00154 // These methods are inherited from DocumentHandler ... 00155 00156 virtual void 00157 startDocument(); 00158 00159 virtual void 00160 endDocument(); 00161 00162 virtual void 00163 startElement( 00164 const XMLCh* const name, 00165 AttributeList& attrs); 00166 00167 virtual void 00168 endElement(const XMLCh* const name); 00169 00170 virtual void 00171 characters( 00172 const XMLCh* const chars, 00173 const unsigned int length); 00174 00175 // These methods are inherited from FormatterToXML... 00176 00177 virtual bool 00178 accumDefaultEntity( 00179 XalanDOMChar ch, 00180 unsigned int i, 00181 const XalanDOMChar chars[], 00182 unsigned int len, 00183 bool escLF); 00184 00185 // These methods are inherited from FormatterListener ... 00186 00187 virtual void 00188 entityReference(const XMLCh* const name); 00189 00190 virtual void 00191 cdata( 00192 const XMLCh* const ch, 00193 const unsigned int length); 00194 00195 virtual void 00196 processingInstruction( 00197 const XMLCh* const target, 00198 const XMLCh* const data); 00199 00200 00201 const PrefixResolver* 00202 getPrefixResolver() const 00203 { 00204 return m_prefixResolver; 00205 } 00206 00207 void 00208 setPrefixResolver(const PrefixResolver* thePrefixResolver) 00209 { 00210 m_prefixResolver = thePrefixResolver; 00211 } 00212 00213 class ElemDesc 00214 { 00215 public: 00216 00217 enum eFlags 00218 { 00219 EMPTY = (1 << 1), 00220 FLOW = (1 << 2), 00221 BLOCK = (1 << 3), 00222 BLOCKFORM = (1 << 4), 00223 BLOCKFORMFIELDSET = (1 << 5), 00224 CDATA = (1 << 6), 00225 PCDATA = (1 << 7), 00226 RAW = (1 << 8), 00227 INLINE = (1 << 9), 00228 INLINEA = (1 << 10), 00229 INLINELABEL = (1 << 11), 00230 FONTSTYLE = (1 << 12), 00231 PHRASE = (1 << 13), 00232 FORMCTRL = (1 << 14), 00233 SPECIAL = (1 << 15), 00234 ASPECIAL = (1 << 16), 00235 HEADMISC = (1 << 17), 00236 HEAD = (1 << 18), 00237 LIST = (1 << 19), 00238 PREFORMATTED = (1 << 20), 00239 WHITESPACESENSITIVE = (1 << 21), 00240 HEADELEM = (1 << 22), 00241 00242 ATTRURL = (1 << 1), 00243 ATTREMPTY = (1 << 2) 00244 }; 00245 00246 ElemDesc(unsigned int flags = 0) : 00247 m_flags(flags) 00248 { 00249 } 00250 00251 ~ElemDesc() 00252 { 00253 } 00254 00255 bool 00256 operator==(const ElemDesc& theRHS) const 00257 { 00258 return m_flags == theRHS.m_flags && m_attrs == theRHS.m_attrs; 00259 } 00260 00261 bool 00262 is(unsigned int flags) const 00263 { 00264 return m_flags & flags ? true : false; 00265 } 00266 00267 void 00268 setAttr( 00269 const XalanDOMChar* name, 00270 unsigned int flags) 00271 { 00272 m_attrs.insert(AttributeMapType::value_type(name, flags)); 00273 } 00274 00275 bool 00276 isAttrFlagSet( 00277 const XalanDOMChar* name, 00278 unsigned int flags) const 00279 { 00280 const AttributeMapType::const_iterator i = 00281 m_attrs.find(name); 00282 00283 if (i == m_attrs.end()) 00284 { 00285 return false; 00286 } 00287 else 00288 { 00289 return (*i).second & flags ? true : false; 00290 } 00291 } 00292 00293 private: 00294 00295 typedef XalanArrayKeyMap< 00296 XalanDOMChar, 00297 unsigned int, 00298 less_no_case_ascii_wide_string> AttributeMapType; 00299 00300 const unsigned int m_flags; 00301 00302 AttributeMapType m_attrs; 00303 }; 00304 00305 00306 typedef XalanArrayKeyMap< 00307 XalanDOMChar, 00308 ElemDesc, 00309 less_no_case_ascii_wide_string> ElementFlagsMapType; 00310 00311 protected: 00312 00313 virtual void 00314 writeAttrString( 00315 const XalanDOMChar* string, 00316 const XalanDOMString& encoding); 00317 00318 virtual void 00319 accumCommentData(const XalanDOMChar* data); 00320 00321 void 00322 writeCharacters(const XalanDOMString& theString); 00323 00324 void 00325 writeCharacters( 00326 const XalanDOMChar* theString, 00327 unsigned int theLength = unsigned(-1)); 00328 00329 private: 00330 00331 static const ElementFlagsMapType& s_elementFlags; 00332 00333 static const XalanEntityReferenceType& s_xalanHTMLEntities; 00334 00335 static const XalanEntityReferenceType::const_iterator& s_xalanHTMLEntitiesIteratorEnd; 00336 00340 static const ElemDesc s_dummyDesc; 00341 00345 static const XalanDOMString& s_doctypeHeaderStartString; 00346 00350 static const XalanDOMString& s_doctypeHeaderPublicString; 00351 00355 static const XalanDOMString& s_doctypeHeaderSystemString; 00356 00360 static const XalanDOMString& s_scriptString; 00361 00365 static const XalanDOMString& s_styleString; 00366 00370 static const XalanDOMString& s_fnofString; 00371 00375 static const XalanDOMString& s_metaString; 00376 00380 void 00381 initAttrCharsMap(); 00382 00386 void 00387 initCharsMap(); 00388 00389 void 00390 copyEntityIntoBuffer(const XalanDOMChar* s); 00391 00392 void 00393 copyEntityIntoBuffer(const XalanDOMString& s); 00394 00401 static const ElemDesc& 00402 getElemDesc(const XalanDOMChar* name); 00403 00409 static void 00410 initializeElementFlagsMap(ElementFlagsMapType&); 00411 00417 static void 00418 initializeXalanEntityReferenceMap(XalanEntityReferenceType&); 00419 00425 virtual void 00426 processAttribute( 00427 const XalanDOMChar* name, 00428 const XalanDOMChar* value, 00429 const ElemDesc& elemDesc); 00430 00438 void 00439 writeAttrURI( 00440 const XalanDOMChar* string, 00441 const XalanDOMString encoding); 00442 00450 void 00451 accumHexNumber(const XalanDOMChar theChar); 00452 00453 bool 00454 popHasNamespace(); 00455 00456 bool 00457 pushHasNamespace(const XalanDOMChar* theElementName); 00458 00459 // Data members... 00460 XalanDOMString m_currentElementName; 00461 00462 bool m_inBlockElem; 00463 00464 BoolStackType m_isRawStack; 00465 00466 bool m_isScriptOrStyleElem; 00467 00468 bool m_escapeURLs; 00469 00474 bool m_isFirstElement; 00475 00479 int m_elementLevel; 00480 00484 const PrefixResolver* m_prefixResolver; 00485 00490 BoolStackType m_hasNamespaceStack; 00491 00492 static const XalanDOMString s_emptyString; 00493 }; 00494 00495 00496 00497 #endif // FORMATTERTOHTML_HEADER_GUARD_1357924680
Doxygen and GraphViz are used to generate this API documentation from the Xalan-C header files.
![]() |
Xalan-C++ XSL Transformer Version 1.1 |
|