Xalan-C++ API Documentation

The Xalan C++ XSLT Processor Version 1.4

Main Page   Namespace List   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-2002 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 <XMLSupport/XMLSupportDefinitions.hpp>
00064 
00065 
00066 
00067 #include <vector>
00068 
00069 
00070 
00071 // Base class header file.
00072 #include <XMLSupport/FormatterToXML.hpp>
00073 
00074 
00075 
00076 #include <PlatformSupport/DOMStringHelper.hpp>
00077 
00078 
00079 
00080 #include <XMLSupport/XalanHTMLElementsProperties.hpp>
00081 
00082 
00083 
00087 class XALAN_XMLSUPPORT_EXPORT FormatterToHTML : public FormatterToXML 
00088 {  
00089 public:
00090 
00091 #if defined(XALAN_NO_NAMESPACES)
00092     typedef vector<XalanHTMLElementsProperties::ElementProperties>  ElementPropertiesStackType;
00093 #else
00094     typedef std::vector<XalanHTMLElementsProperties::ElementProperties> ElementPropertiesStackType;
00095 #endif
00096 
00097     enum
00098     {
00099         eDefaultIndentAmount = 0
00100     };
00101 
00113     FormatterToHTML(
00114             Writer&                 writer,
00115             const XalanDOMString&   encoding = XalanDOMString(),
00116             const XalanDOMString&   mediaType = XalanDOMString(),
00117             const XalanDOMString&   doctypeSystem = XalanDOMString(),
00118             const XalanDOMString&   doctypePublic = XalanDOMString(),
00119             bool                    doIndent = true,
00120             int                     indent = eDefaultIndentAmount,
00121             bool                    escapeURLs = true,
00122             bool                    omitMetaTag = false);
00123 
00124     virtual
00125     ~FormatterToHTML();
00126 
00127     // These methods are inherited from DocumentHandler ...
00128 
00129     virtual void
00130     startDocument();
00131 
00132     virtual void
00133     endDocument();
00134 
00135     virtual void
00136     startElement(
00137             const   XMLCh* const    name,
00138             AttributeList&          attrs);
00139 
00140     virtual void
00141     endElement(const XMLCh* const   name);
00142 
00143     virtual void
00144     characters(
00145             const XMLCh* const  chars,
00146             const unsigned int  length);
00147 
00148     // These methods are inherited from FormatterToXML...
00149 
00150     virtual bool
00151     accumDefaultEntity(
00152             XalanDOMChar                ch,
00153             XalanDOMString::size_type   i,
00154             const XalanDOMChar          chars[],
00155             XalanDOMString::size_type   len,
00156             bool                        escLF);
00157 
00158     // These methods are inherited from FormatterListener ...
00159 
00160     virtual void
00161     entityReference(const XMLCh* const  name);
00162 
00163     virtual void
00164     cdata(
00165             const XMLCh* const  ch,
00166             const unsigned int  length);
00167 
00168     virtual void
00169     processingInstruction(
00170             const XMLCh* const  target,
00171             const XMLCh* const  data);
00172 
00173 
00174     bool
00175     getEscapeURLs() const
00176     {
00177         return m_escapeURLs;
00178     }
00179 
00180     void
00181     setEscapeURLs(bool  flag)
00182     {
00183         m_escapeURLs = flag;
00184     }
00185 
00186     struct Entity
00187     {
00188         enum { eMaxLength = 8 };
00189 
00190         XalanDOMChar                m_char;
00191 
00192         XalanDOMString::size_type   m_length;
00193 
00194         XalanDOMChar                m_string[eMaxLength + 1];
00195     };
00196 
00197 protected:
00198 
00199     virtual void
00200     writeAttrString(const XalanDOMChar*     theString);
00201 
00202     virtual void
00203     accumCommentData(const XalanDOMChar*    data);
00204 
00205     void
00206     writeCharacters(const XalanDOMString&   theString);
00207 
00208     void
00209     writeCharacters(
00210             const XalanDOMChar*         theString,
00211             XalanDOMString::size_type   theLength = XalanDOMString::npos);
00212 
00213 private:
00214 
00215     typedef XalanDOMString::size_type   size_type;
00216 
00220     static const XalanDOMChar   s_doctypeHeaderStartString[];
00221 
00222     static const size_type      s_doctypeHeaderStartStringLength;
00223 
00227     static const XalanDOMChar   s_doctypeHeaderPublicString[];
00228 
00229     static const size_type      s_doctypeHeaderPublicStringLength;
00230 
00234     static const XalanDOMChar   s_doctypeHeaderSystemString[];
00235 
00236     static const size_type      s_doctypeHeaderSystemStringLength;
00237 
00241     static const XalanDOMChar   s_scriptString[];
00242 
00243     static const size_type      s_scriptStringLength;
00244 
00248     static const XalanDOMChar   s_styleString[];
00249 
00250     static const size_type      s_styleStringLength;
00251 
00255     static const XalanDOMChar   s_metaString[];
00256 
00257     static const size_type      s_metaStringLength;
00258 
00262     void
00263     initAttrCharsMap();
00264 
00268     void
00269     initCharsMap();
00270 
00271     void
00272     copyEntityIntoBuffer(
00273             const XalanDOMChar*         s,
00274             XalanDOMString::size_type   theLength);
00275 
00276     void
00277     copyEntityIntoBuffer(const XalanDOMString&  s);
00278 
00284     virtual void
00285     processAttribute(
00286             const XalanDOMChar*                                     name,
00287             const XalanDOMChar*                                     value,
00288             const XalanHTMLElementsProperties::ElementProperties&   elemProperties);
00289 
00296     void
00297     writeAttrURI(const XalanDOMChar*    theString);
00298 
00306     void
00307     accumHexNumber(const XalanDOMChar   theChar);
00308 
00309     bool
00310     popHasNamespace();
00311 
00312     bool
00313     pushHasNamespace(const XalanDOMChar*    theElementName);
00314 
00315     // Data members...
00316     XalanDOMString          m_currentElementName;
00317 
00318     bool                    m_inBlockElem;
00319 
00320     BoolStackType           m_isRawStack;
00321 
00322     bool                    m_isScriptOrStyleElem;
00323 
00324     BoolStackType           m_inScriptElemStack;
00325 
00326     bool                    m_escapeURLs;
00327 
00332     bool                    m_isFirstElement;
00333 
00337     bool                    m_isUTF8;
00338 
00342     int                     m_elementLevel;
00343 
00348     BoolStackType           m_hasNamespaceStack;
00349 
00353     bool                    m_omitMetaTag;
00354 
00355     ElementPropertiesStackType      m_elementPropertiesStack;
00356 
00357     static const XalanDOMString     s_emptyString;
00358 
00359     static const Entity             s_entities[];
00360 
00361     static const Entity* const      s_lastEntity;
00362 };
00363 
00364 
00365 
00366 #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.4
Copyright © 2000, 2001, 2002 The Apache Software Foundation. All Rights Reserved.