Xalan-C++ API Documentation

The Xalan C++ XSL Transformer Version 1.1

Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

FormatterToHTML.hpp

Go to the documentation of this file.
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 
00097 class XALAN_XMLSUPPORT_EXPORT FormatterToHTML : public FormatterToXML 
00098 {  
00099 
00100 public:
00101 
00102 #if defined(XALAN_NO_NAMESPACES)
00103     typedef map<XalanDOMChar,
00104                 XalanDOMString,
00105                 less<XalanDOMChar> >    XalanEntityReferenceMapType;
00106 #else
00107     typedef std::map<XalanDOMChar,
00108                      XalanDOMString>    XalanEntityReferenceMapType;    
00109 #endif
00110 
00114     static void
00115     initialize();
00116 
00120     static void
00121     terminate();
00122 
00123     enum eDummy
00124     {
00125         eDefaultIndentAmount = 0
00126     };
00127 
00135     FormatterToHTML(
00136             Writer&                 writer,
00137             const XalanDOMString&   encoding = XalanDOMString(),
00138             const XalanDOMString&   mediaType = XalanDOMString(),
00139             const XalanDOMString&   doctypeSystem = XalanDOMString(),
00140             const XalanDOMString&   doctypePublic = XalanDOMString(),
00141             bool                    doIndent = true,
00142             int                     indent = eDefaultIndentAmount,
00143             const XalanDOMString&   version = XalanDOMString(),
00144             const XalanDOMString&   standalone = XalanDOMString(),
00145             bool                    xmlDecl = false);
00146 
00147     virtual
00148     ~FormatterToHTML();
00149 
00150     // These methods are inherited from DocumentHandler ...
00151 
00152     virtual void
00153     startDocument();
00154 
00155     virtual void
00156     endDocument();
00157 
00158     virtual void
00159     startElement(
00160             const   XMLCh* const    name,
00161             AttributeList&          attrs);
00162 
00163     virtual void
00164     endElement(const XMLCh* const   name);
00165 
00166     virtual void
00167     characters(
00168             const XMLCh* const  chars,
00169             const unsigned int  length);
00170 
00171     // These methods are inherited from FormatterToXML...
00172 
00173     virtual bool
00174     accumDefaultEntity(
00175             XalanDOMChar        ch,
00176             unsigned int        i,
00177             const XalanDOMChar  chars[],
00178             unsigned int        len,
00179             bool                escLF);
00180 
00181     // These methods are inherited from FormatterListener ...
00182 
00183     virtual void
00184     entityReference(const XMLCh* const  name);
00185 
00186     virtual void
00187     cdata(
00188             const XMLCh* const  ch,
00189             const unsigned int  length);
00190 
00191     virtual void
00192     processingInstruction(
00193             const XMLCh* const  target,
00194             const XMLCh* const  data);
00195 
00196 
00197     class ElemDesc
00198     {
00199     public:
00200 
00201         enum eFlags
00202         {
00203             EMPTY = (1 << 1),
00204             FLOW = (1 << 2),
00205             BLOCK = (1 << 3),
00206             BLOCKFORM = (1 << 4),
00207             BLOCKFORMFIELDSET = (1 << 5),
00208             CDATA = (1 << 6),
00209             PCDATA = (1 << 7),
00210             RAW = (1 << 8),
00211             INLINE = (1 << 9),
00212             INLINEA = (1 << 10),
00213             INLINELABEL = (1 << 11),
00214             FONTSTYLE = (1 << 12),
00215             PHRASE = (1 << 13),
00216             FORMCTRL = (1 << 14),
00217             SPECIAL = (1 << 15),
00218             ASPECIAL = (1 << 16),
00219             HEADMISC = (1 << 17),
00220             HEAD = (1 << 18),
00221             LIST = (1 << 19),
00222             PREFORMATTED = (1 << 20),
00223             WHITESPACESENSITIVE = (1 << 21),
00224             HEADELEM = (1 << 22),
00225 
00226             ATTRURL = (1 << 1),
00227             ATTREMPTY = (1 << 2)
00228         };
00229 
00230         ElemDesc(unsigned int   flags = 0) :
00231             m_flags(flags)
00232         {
00233         }
00234 
00235         ~ElemDesc()
00236         {
00237         }
00238 
00239         bool
00240         operator==(const ElemDesc&  theRHS) const
00241         {
00242             return m_flags == theRHS.m_flags && m_attrs == theRHS.m_attrs;
00243         }
00244 
00245         bool
00246         is(unsigned int     flags) const
00247         {
00248             return m_flags & flags ? true : false;
00249         }
00250 
00251         void
00252         setAttr(
00253                 const XalanDOMChar*     name,
00254                 unsigned int            flags)
00255         {
00256             m_attrs.insert(AttributeMapType::value_type(name, flags));
00257         }
00258 
00259         bool
00260         isAttrFlagSet(
00261                 const XalanDOMChar*     name,
00262                 unsigned int            flags) const
00263         {
00264             const AttributeMapType::const_iterator  i =
00265                 m_attrs.find(name);
00266 
00267             if (i == m_attrs.end())
00268             {
00269                 return false;
00270             }
00271             else
00272             {
00273                 return (*i).second & flags ? true : false;
00274             }
00275         }
00276 
00277     private:
00278 
00279         typedef XalanArrayKeyMap<
00280                     XalanDOMChar,
00281                     unsigned int,
00282                     less_no_case_ascii_wide_string>     AttributeMapType;
00283 
00284         const unsigned int  m_flags;
00285 
00286         AttributeMapType    m_attrs;
00287     };
00288 
00289 
00290     typedef XalanArrayKeyMap<
00291                 XalanDOMChar,
00292                 ElemDesc,
00293                 less_no_case_ascii_wide_string>     ElementFlagsMapType;
00294 
00295 protected:
00296 
00297     virtual void
00298     writeAttrString(const XalanDOMChar*     theString);
00299 
00300     virtual void
00301     accumCommentData(const XalanDOMChar*    data);
00302 
00303     void
00304     writeCharacters(const XalanDOMString&   theString);
00305 
00306     void
00307     writeCharacters(
00308             const XalanDOMChar*     theString,
00309             unsigned int            theLength = unsigned(-1));
00310 
00311 private:
00312 
00313     static const ElementFlagsMapType&                           s_elementFlags;
00314 
00315     static const XalanEntityReferenceMapType&                   s_xalanHTMLEntities;
00316 
00317     static const XalanEntityReferenceMapType::const_iterator&   s_xalanHTMLEntitiesIteratorEnd; 
00318 
00322     static const ElemDesc           s_dummyDesc;
00323 
00327     static const XalanDOMString&    s_doctypeHeaderStartString;
00328 
00332     static const XalanDOMString&    s_doctypeHeaderPublicString;
00333 
00337     static const XalanDOMString&    s_doctypeHeaderSystemString;
00338 
00342     static const XalanDOMString&    s_scriptString;
00343 
00347     static const XalanDOMString&    s_styleString;
00348 
00352     static const XalanDOMString&    s_fnofString;
00353 
00357     static const XalanDOMString&    s_metaString;
00358 
00362     void
00363     initAttrCharsMap();
00364 
00368     void
00369     initCharsMap();
00370 
00371     void
00372     copyEntityIntoBuffer(const XalanDOMChar*    s);
00373 
00374     void
00375     copyEntityIntoBuffer(const XalanDOMString&  s);
00376 
00383     static const ElemDesc&
00384     getElemDesc(const XalanDOMChar*     name);
00385 
00391     static void
00392     initializeElementFlagsMap(ElementFlagsMapType&  theMap);
00393 
00399     static void
00400     initializeXalanEntityReferenceMap(XalanEntityReferenceMapType&  theMap);
00401 
00407     virtual void
00408     processAttribute(
00409             const XalanDOMChar*     name,
00410             const XalanDOMChar*     value,
00411             const ElemDesc&         elemDesc);
00412 
00419     void
00420     writeAttrURI(const XalanDOMChar*    theString);
00421 
00429     void
00430     accumHexNumber(const XalanDOMChar   theChar);
00431 
00432     bool
00433     popHasNamespace();
00434 
00435     bool
00436     pushHasNamespace(const XalanDOMChar*    theElementName);
00437 
00438     // Data members...
00439     XalanDOMString          m_currentElementName;
00440 
00441     bool                    m_inBlockElem;
00442 
00443     BoolStackType           m_isRawStack;
00444 
00445     bool                    m_isScriptOrStyleElem;
00446 
00447     bool                    m_escapeURLs;
00448 
00453     bool                    m_isFirstElement;
00454 
00458     bool                    m_isUTF8;
00459 
00463     int                     m_elementLevel;
00464 
00469     BoolStackType           m_hasNamespaceStack;
00470 
00471     static const XalanDOMString     s_emptyString;
00472 };
00473 
00474 
00475 
00476 #endif  // FORMATTERTOHTML_HEADER_GUARD_1357924680

Interpreting class diagrams

Doxygen and GraphViz are used to generate this API documentation from the Xalan-C header files.

Xalan-C++ XSL Transformer Version 1.1
Copyright © 2000, 2001 The Apache Software Foundation. All Rights Reserved.