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 <PlatformSupport/DOMStringHelper.hpp> 00087 00088 00089 00090 #include <XPath/QName.hpp> 00091 00092 00093 00097 class XALAN_XMLSUPPORT_EXPORT FormatterToHTML : public FormatterToXML 00098 { 00099 00100 public: 00101 00105 static void 00106 initialize(); 00107 00111 static void 00112 terminate(); 00113 00114 enum eDummy 00115 { 00116 eDefaultIndentAmount = 4 00117 }; 00118 00126 FormatterToHTML( 00127 Writer& writer, 00128 const XalanDOMString& encoding = XalanDOMString(), 00129 const XalanDOMString& mediaType = XalanDOMString(), 00130 const XalanDOMString& doctypeSystem = XalanDOMString(), 00131 const XalanDOMString& doctypePublic = XalanDOMString(), 00132 bool doIndent = true, 00133 int indent = eDefaultIndentAmount, 00134 const XalanDOMString& version = XalanDOMString(), 00135 const XalanDOMString& standalone = XalanDOMString(), 00136 bool xmlDecl = false); 00137 00138 virtual 00139 ~FormatterToHTML(); 00140 00141 // These methods are inherited from DocumentHandler ... 00142 00143 virtual void 00144 startDocument(); 00145 00146 virtual void 00147 startElement( 00148 const XMLCh* const name, 00149 AttributeList& attrs); 00150 00151 virtual void 00152 endElement(const XMLCh* const name); 00153 00154 virtual void 00155 characters( 00156 const XMLCh* const chars, 00157 const unsigned int length); 00158 00159 00160 // These methods are inherited from FormatterListener ... 00161 00162 virtual void 00163 entityReference(const XMLCh* const name); 00164 00165 00166 virtual void 00167 cdata( 00168 const XMLCh* const ch, 00169 const unsigned int length); 00170 00171 virtual void 00172 processingInstruction( 00173 const XMLCh* const target, 00174 const XMLCh* const data); 00175 00176 00177 class ElemDesc 00178 { 00179 public: 00180 00181 enum eFlags 00182 { 00183 EMPTY = (1 << 1), 00184 FLOW = (1 << 2), 00185 BLOCK = (1 << 3), 00186 BLOCKFORM = (1 << 4), 00187 BLOCKFORMFIELDSET = (1 << 5), 00188 CDATA = (1 << 6), 00189 PCDATA = (1 << 7), 00190 RAW = (1 << 8), 00191 INLINE = (1 << 9), 00192 INLINEA = (1 << 10), 00193 INLINELABEL = (1 << 11), 00194 FONTSTYLE = (1 << 12), 00195 PHRASE = (1 << 13), 00196 FORMCTRL = (1 << 14), 00197 SPECIAL = (1 << 15), 00198 ASPECIAL = (1 << 16), 00199 HEADMISC = (1 << 17), 00200 HEAD = (1 << 18), 00201 LIST = (1 << 19), 00202 PREFORMATTED = (1 << 20), 00203 WHITESPACESENSITIVE = (1 << 21), 00204 00205 ATTRURL = (1 << 1), 00206 ATTREMPTY = (1 << 2) 00207 }; 00208 00209 ElemDesc(unsigned int flags = 0) : 00210 m_flags(flags) 00211 { 00212 } 00213 00214 ~ElemDesc() 00215 { 00216 } 00217 00218 bool 00219 is(unsigned int flags) const 00220 { 00221 return m_flags & flags ? true : false; 00222 } 00223 00224 void 00225 setAttr( 00226 const XalanDOMString& name, 00227 unsigned int flags) 00228 { 00229 m_attrs.insert(AttributeMapType::value_type(name, flags)); 00230 } 00231 00232 bool 00233 isAttrFlagSet( 00234 const XalanDOMString& name, 00235 unsigned int flags) const 00236 { 00237 const AttributeMapType::const_iterator i = 00238 m_attrs.find(name); 00239 00240 if (i == m_attrs.end()) 00241 { 00242 return false; 00243 } 00244 else 00245 { 00246 return (*i).second & flags ? true : false; 00247 } 00248 } 00249 00250 private: 00251 00252 #if defined(XALAN_NO_NAMESPACES) 00253 typedef map<XalanDOMString, unsigned int, less<XalanDOMString> > AttributeMapType; 00254 #else 00255 typedef std::map<XalanDOMString, unsigned int> AttributeMapType; 00256 #endif 00257 00258 const unsigned int m_flags; 00259 00260 AttributeMapType m_attrs; 00261 }; 00262 00263 00264 #if defined(XALAN_NO_NAMESPACES) 00265 typedef map<XalanDOMString, 00266 ElemDesc, 00267 less<XalanDOMString> > ElementFlagsMapType; 00268 #else 00269 typedef std::map<XalanDOMString, ElemDesc> ElementFlagsMapType; 00270 #endif 00271 00272 protected: 00273 00274 // These methods are new ... 00280 virtual void 00281 writeAttrString( 00282 const XalanDOMChar* string, 00283 const XalanDOMString& encoding); 00284 00285 private: 00286 00287 static const ElementFlagsMapType& s_elementFlags; 00288 00292 static const ElemDesc s_dummyDesc; 00293 00297 static const XalanDOMCharVectorType& s_doctypeHeaderStartString; 00298 00302 static const XalanDOMCharVectorType& s_doctypeHeaderPublicString; 00303 00307 static const XalanDOMCharVectorType& s_doctypeHeaderSystemString; 00308 00312 static const XalanDOMCharVectorType& s_scriptString; 00313 00317 static const XalanDOMCharVectorType& s_styleString; 00318 00322 static const XalanDOMCharVectorType& s_ltString; 00323 00327 static const XalanDOMCharVectorType& s_gtString; 00328 00332 static const XalanDOMCharVectorType& s_ampString; 00333 00337 static const XalanDOMCharVectorType& s_fnofString; 00338 00342 void 00343 initAttrCharsMap(); 00344 00348 void 00349 initCharsMap(); 00350 00351 unsigned int 00352 copyEntityIntoBuffer( 00353 const XalanDOMChar* s, 00354 unsigned int pos); 00355 00356 unsigned int 00357 copyEntityIntoBuffer( 00358 const XalanDOMString& s, 00359 unsigned int pos) 00360 { 00361 return copyEntityIntoBuffer(c_wstr(s), pos); 00362 } 00363 00364 unsigned int 00365 copyEntityIntoBuffer( 00366 const XalanDOMCharVectorType& s, 00367 unsigned int pos) 00368 { 00369 return copyEntityIntoBuffer(c_wstr(s), pos); 00370 } 00371 00378 static const ElemDesc& 00379 getElemDesc(const XalanDOMString& name); 00380 00386 static void 00387 initializeElementFlagsMap(ElementFlagsMapType& ); 00388 00394 virtual void 00395 processAttribute( 00396 const XalanDOMChar* name, 00397 const XalanDOMChar* value, 00398 const ElemDesc& elemDesc); 00399 00408 void 00409 writeAttrURI( 00410 const XalanDOMChar* string, 00411 const XalanDOMString encoding); 00412 00413 XalanDOMString m_currentElementName; 00414 00415 bool m_inBlockElem; 00416 00417 BoolStackType m_isRawStack; 00418 }; 00419 00420 00421 00422 #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.0 |
|