## Xalan-C++ API Documentation

### The Xalan C++ XSLT Processor Version 1.7

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-2004 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
    00060
    00061
    00062 // Base include file.  Must be first.
    00063 #include <xalanc/XMLSupport/XMLSupportDefinitions.hpp>
    00064
    00065
    00066
    00067 #include <vector>
    00068
    00069
    00070
    00071 // Base class header file.
    00072 #include <xalanc/XMLSupport/FormatterToXML.hpp>
    00073
    00074
    00075
    00076 #include <xalanc/PlatformSupport/DOMStringHelper.hpp>
    00077
    00078
    00079
    00080 #include <xalanc/XMLSupport/XalanHTMLElementsProperties.hpp>
    00081
    00082
    00083
    00084 XALAN_CPP_NAMESPACE_BEGIN
    00085
    00086
    00087
    00091 class XALAN_XMLSUPPORT_EXPORT FormatterToHTML : public FormatterToXML
    00092 {
    00093 public:
    00094
    00095 #if defined(XALAN_NO_STD_NAMESPACE)
    00096     typedef vector<XalanHTMLElementsProperties::ElementProperties>  ElementPropertiesStackType;
    00097 #else
    00098     typedef std::vector<XalanHTMLElementsProperties::ElementProperties> ElementPropertiesStackType;
    00099 #endif
    00100
    00101     enum
    00102     {
    00103         eDefaultIndentAmount = 0
    00104     };
    00105
    00117     FormatterToHTML(
    00118             Writer&                 writer,
    00119             const XalanDOMString&   encoding = XalanDOMString(),
    00120             const XalanDOMString&   mediaType = XalanDOMString(),
    00121             const XalanDOMString&   doctypeSystem = XalanDOMString(),
    00122             const XalanDOMString&   doctypePublic = XalanDOMString(),
    00123             bool                    doIndent = true,
    00124             int                     indent = eDefaultIndentAmount,
    00125             bool                    escapeURLs = true,
    00126             bool                    omitMetaTag = false);
    00127
    00128     virtual
    00129     ~FormatterToHTML();
    00130
    00131     // These methods are inherited from DocumentHandler ...
    00132
    00133     virtual void
    00134     startDocument();
    00135
    00136     virtual void
    00137     endDocument();
    00138
    00139     virtual void
    00140     startElement(
    00141             const   XMLCh* const    name,
    00142             AttributeListType&      attrs);
    00143
    00144     virtual void
    00145     endElement(const XMLCh* const   name);
    00146
    00147     virtual void
    00148     characters(
    00149             const XMLCh* const  chars,
    00150             const unsigned int  length);
    00151
    00152     // These methods are inherited from FormatterToXML...
    00153
    00154     virtual bool
    00155     accumDefaultEntity(
    00156             XalanDOMChar                ch,
    00157             bool                        escLF);
    00158
    00159     // These methods are inherited from FormatterListener ...
    00160
    00161     virtual void
    00162     entityReference(const XMLCh* const  name);
    00163
    00164     virtual void
    00165     cdata(
    00166             const XMLCh* const  ch,
    00167             const unsigned int  length);
    00168
    00169     virtual void
    00170     processingInstruction(
    00171             const XMLCh* const  target,
    00172             const XMLCh* const  data);
    00173
    00174
    00175     bool
    00176     getEscapeURLs() const
    00177     {
    00178         return m_escapeURLs;
    00179     }
    00180
    00181     void
    00182     setEscapeURLs(bool  flag)
    00183     {
    00184         m_escapeURLs = flag;
    00185     }
    00186
    00187     struct Entity
    00188     {
    00189         enum { eMaxLength = 8 };
    00190
    00191         XalanDOMChar                m_char;
    00192
    00193         XalanDOMString::size_type   m_length;
    00194
    00195         XalanDOMChar                m_string[eMaxLength + 1];
    00196     };
    00197
    00198 protected:
    00199
    00200     virtual void
    00201     writeAttrString(
    00202             const XalanDOMChar*         theString,
    00203             XalanDOMString::size_type   theStringLength);
    00204
    00205     virtual void
    00206     accumCommentData(const XalanDOMChar*    data);
    00207
    00208     void
    00209     writeCharacters(const XalanDOMString&   theString);
    00210
    00211     void
    00212     writeCharacters(
    00213             const XalanDOMChar*         theString,
    00214             XalanDOMString::size_type   theLength);
    00215
    00216 private:
    00217
    00218     typedef XalanDOMString::size_type   size_type;
    00219
    00223     static const XalanDOMChar   s_doctypeHeaderStartString[];
    00224
    00225     static const size_type      s_doctypeHeaderStartStringLength;
    00226
    00230     static const XalanDOMChar   s_doctypeHeaderPublicString[];
    00231
    00232     static const size_type      s_doctypeHeaderPublicStringLength;
    00233
    00237     static const XalanDOMChar   s_doctypeHeaderSystemString[];
    00238
    00239     static const size_type      s_doctypeHeaderSystemStringLength;
    00240
    00244     static const XalanDOMChar   s_metaString[];
    00245
    00246     static const size_type      s_metaStringLength;
    00247
    00251     void
    00252     initAttrCharsMap();
    00253
    00257     void
    00258     initCharsMap();
    00259
    00260     void
    00261     copyEntityIntoBuffer(
    00262             const XalanDOMChar*         s,
    00263             XalanDOMString::size_type   theLength);
    00264
    00265     void
    00266     copyEntityIntoBuffer(const XalanDOMString&  s);
    00267
    00273     virtual void
    00274     processAttribute(
    00275             const XalanDOMChar*                                     name,
    00276             const XalanDOMChar*                                     value,
    00277             const XalanHTMLElementsProperties::ElementProperties&   elemProperties);
    00278
    00286     void
    00287     writeAttrURI(
    00288             const XalanDOMChar*         theString,
    00289             XalanDOMString::size_type   theStringLength);
    00290
    00298     void
    00299     accumHexNumber(XalanDOMChar     theChar);
    00300
    00301     bool
    00302     popHasNamespace();
    00303
    00304     bool
    00305     pushHasNamespace(const XalanDOMChar*    theElementName);
    00306
    00307     // Data members...
    00308     XalanDOMString          m_currentElementName;
    00309
    00310     bool                    m_inBlockElem;
    00311
    00312     BoolStackType           m_isRawStack;
    00313
    00314     bool                    m_isScriptOrStyleElem;
    00315
    00316     BoolStackType           m_inScriptElemStack;
    00317
    00318     bool                    m_escapeURLs;
    00319
    00324     bool                    m_isFirstElement;
    00325
    00329     bool                    m_isUTF8;
    00330
    00334     int                     m_elementLevel;
    00335
    00340     BoolStackType           m_hasNamespaceStack;
    00341
    00345     bool                    m_omitMetaTag;
    00346
    00347     ElementPropertiesStackType      m_elementPropertiesStack;
    00348
    00349     static const XalanDOMString     s_emptyString;
    00350
    00351     static const Entity             s_entities[];
    00352
    00353     static const Entity* const      s_lastEntity;
    00354 };
    00355
    00356
    00357
    00358 XALAN_CPP_NAMESPACE_END
    00359
    00360
    00361
    00362 #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++ XSLT Processor Version 1.7 Copyright © 1999-2004 The Apache Software Foundation. All Rights Reserved.