## 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

# FormatterToXML_UTF8.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(FORMATTERTOXML_UTF8_HEADER_GUARD_1357924680)
    00058 #define FORMATTERTOXML_UTF8_HEADER_GUARD_1357924680
    00059
    00060
    00061
    00062
    00063 // Base include file.  Must be first.
    00064 #include <xalanc/XMLSupport/XMLSupportDefinitions.hpp>
    00065
    00066
    00067
    00068 #include <xalanc/XalanDOM/XalanDOMString.hpp>
    00069
    00070
    00071
    00072 // Base class header file.
    00073 #include "FormatterToXMLBase.hpp"
    00074
    00075
    00076
    00077 XALAN_CPP_NAMESPACE_BEGIN
    00078
    00079
    00080
    00084 class XALAN_XMLSUPPORT_EXPORT FormatterToXML_UTF8 : public FormatterToXMLBase
    00085 {
    00086 public:
    00087
    00091     static void
    00092     initialize();
    00093
    00097     static void
    00098     terminate();
    00099
    00115     FormatterToXML_UTF8(
    00116             Writer&                 writer,
    00117             const XalanDOMString&   version = XalanDOMString(),
    00118             const XalanDOMString&   mediaType = XalanDOMString(),
    00119             const XalanDOMString&   doctypeSystem = XalanDOMString(),
    00120             const XalanDOMString&   doctypePublic = XalanDOMString(),
    00121             bool                    xmlDecl = true,
    00122             const XalanDOMString&   standalone = XalanDOMString());
    00123
    00124     virtual
    00125     ~FormatterToXML_UTF8();
    00126
    00127
    00128     // These methods are inherited from FormatterListener ...
    00129
    00130     virtual void
    00131     startElement(
    00132             const XMLCh* const  name,
    00133             AttributeListType&  attrs);
    00134
    00135     virtual void
    00136     endElement(const XMLCh* const   name);
    00137
    00138     virtual void
    00139     charactersRaw(
    00140             const XMLCh* const  chars,
    00141             const unsigned int  length);
    00142
    00143     virtual void
    00144     entityReference(const XMLCh* const  name);
    00145
    00146     virtual void
    00147     comment(const XMLCh* const  data);
    00148
    00149     virtual const XalanDOMString&
    00150     getEncoding() const;
    00151
    00152 protected:
    00153
    00154     virtual void
    00155     writeXMLHeader();
    00156
    00157     virtual void
    00158     flushBuffer();
    00159
    00160     virtual void
    00161     writeDoctypeDecl(const XalanDOMChar*    name);
    00162
    00163     virtual void
    00164     writeProcessingInstruction(
    00165             const XMLCh*    target,
    00166             const XMLCh*    data);
    00167
    00168     virtual void
    00169     writeCharacters(
    00170             const XMLCh*    chars,
    00171             unsigned int    length);
    00172
    00173     virtual void
    00174     writeCDATA(
    00175             const XMLCh*    chars,
    00176             unsigned int    length);
    00177
    00181     void
    00182     outputLineSep();
    00183
    00187     XalanDOMString::size_type
    00188     writeDefaultEscape(
    00189             XalanDOMChar                ch,
    00190             XalanDOMString::size_type   i,
    00191             const XalanDOMChar          chars[],
    00192             XalanDOMString::size_type   len);
    00193
    00197     XalanDOMString::size_type
    00198     writeDefaultAttributeEscape(
    00199             XalanDOMChar                ch,
    00200             XalanDOMString::size_type   i,
    00201             const XalanDOMChar          chars[],
    00202             XalanDOMString::size_type   len);
    00203
    00208     bool
    00209     writeDefaultEntity(XalanDOMChar     ch);
    00210
    00215     bool
    00216     writeDefaultAttributeEntity(XalanDOMChar    ch);
    00217
    00222     void
    00223     writeCommentData(const XalanDOMChar*    data);
    00224
    00229     void
    00230     writeParentTagEnd();
    00231
    00238     XalanDOMString::size_type
    00239     writeNormalizedChar(
    00240             XalanDOMChar                ch,
    00241             const XalanDOMChar          chars[],
    00242             XalanDOMString::size_type   start,
    00243             XalanDOMString::size_type   length);
    00244
    00251     void
    00252     writeCDATAChars(
    00253             const XalanDOMChar          ch[],
    00254             XalanDOMString::size_type   length);
    00255
    00262     void
    00263     writeAttrString(
    00264             const XalanDOMChar*         theString,
    00265             XalanDOMString::size_type   theStringLength);
    00266
    00267 private:
    00268
    00269     // These are not implemented.
    00270     FormatterToXML_UTF8(const FormatterToXML_UTF8&);
    00271
    00272     FormatterToXML_UTF8&
    00273     operator=(const FormatterToXML_UTF8&);
    00274
    00275     bool
    00276     operator==(const FormatterToXML_UTF8&) const;
    00277
    00278     void
    00279     safeWriteContent(
    00280             const XalanDOMChar*         theChars,
    00281             XalanDOMString::size_type   theLength);
    00282
    00283     void
    00284     write(
    00285             const XalanDOMChar*         theChars,
    00286             XalanDOMString::size_type   theLength);
    00287
    00288     void
    00289     writeName1_0(const XalanDOMChar*    theChars);
    00290
    00291     void
    00292     writeName1_1(const XalanDOMChar*    theChars);
    00293
    00294     void
    00295     write(const XalanDOMChar*   theChars)
    00296     {
    00297         write(theChars, XalanDOMString::length(theChars));
    00298     }
    00299
    00300     void
    00301     write(XalanDOMChar  theChar)
    00302     {
    00303         write((unsigned int)theChar);
    00304     }
    00305
    00306     void
    00307     write(unsigned int  theChar);
    00308
    00309     void
    00310     write(const XalanDOMString&     theChars)
    00311     {
    00312         write(theChars.c_str(), theChars.length());
    00313     }
    00314
    00315     void
    00316     write(char  theChar);
    00317
    00318     void
    00319     write(
    00320             const char*                 theChars,
    00321             XalanDOMString::size_type   theLength);
    00322
    00323     void
    00324     write(const char*   theChars)
    00325     {
    00326         write(theChars, XalanDOMString::length(theChars));
    00327     }
    00328
    00334     void
    00335     processAttribute(
    00336             const XalanDOMChar*     name,
    00337             const XalanDOMChar*     value);
    00338
    00344     void
    00345     writeNormalizedPIData(
    00346             const XalanDOMChar*         theData,
    00347             XalanDOMString::size_type   theLength);
    00348
    00349     // Data members...
    00353     static const XalanDOMString&    s_utf8String;
    00354
    00358     static const char                       s_doctypeHeaderStartString[];
    00359
    00360     static const XalanDOMString::size_type  s_doctypeHeaderStartStringLength;
    00361
    00365     static const char                       s_doctypeHeaderPublicString[];
    00366
    00367     static const XalanDOMString::size_type  s_doctypeHeaderPublicStringLength;
    00368
    00372     static const char                       s_doctypeHeaderSystemString[];
    00373
    00374     static const XalanDOMString::size_type  s_doctypeHeaderSystemStringLength;
    00375
    00379     static const char                       s_xmlHeaderStartString[];
    00380
    00381     static const XalanDOMString::size_type  s_xmlHeaderStartStringLength;
    00382
    00386     static const char                       s_xmlHeaderEncodingString[];
    00387
    00388     static const XalanDOMString::size_type  s_xmlHeaderEncodingStringLength;
    00389
    00393     static const char                       s_xmlHeaderStandaloneString[];
    00394
    00395     static const XalanDOMString::size_type  s_xmlHeaderStandaloneStringLength;
    00396
    00400     static const char                       s_xmlHeaderEndString[];
    00401
    00402     static const XalanDOMString::size_type  s_xmlHeaderEndStringLength;
    00403
    00407     static const char                       s_defaultVersionString[];
    00408
    00409     static const XalanDOMString::size_type  s_defaultVersionStringLength;
    00410
    00414     static const XalanDOMChar               s_xhtmlDocTypeString[];
    00415
    00416     static const XalanDOMString::size_type  s_xhtmlDocTypeStringLength;
    00417
    00421     static const char                       s_cdataOpenString[];
    00422
    00423     static const XalanDOMString::size_type  s_cdataOpenStringLength;
    00424
    00428     static const char                       s_cdataCloseString[];
    00429
    00430     static const XalanDOMString::size_type  s_cdataCloseStringLength;
    00431
    00435     static const char                       s_lessThanEntityString[];
    00436
    00437     static const XalanDOMString::size_type  s_lessThanEntityStringLength;
    00438
    00442     static const char                       s_greaterThanEntityString[];
    00443
    00444     static const XalanDOMString::size_type  s_greaterThanEntityStringLength;
    00445
    00449     static const char                       s_ampersandEntityString[];
    00450
    00451     static const XalanDOMString::size_type  s_ampersandEntityStringLength;
    00452
    00456     static const char                       s_quoteEntityString[];
    00457
    00458     static const XalanDOMString::size_type  s_quoteEntityStringLength;
    00459
    00463     static const char                       s_linefeedNCRString[];
    00464
    00465     static const XalanDOMString::size_type  s_linefeedNCRStringLength;
    00466
    00470     static const char                       s_htabNCRString[];
    00471
    00472     static const XalanDOMString::size_type  s_htabNCRStringLength;
    00473
    00474
    00475     typedef void (FormatterToXML_UTF8::*NameFunctionType)(const XalanDOMChar*);
    00476
    00477     NameFunctionType    m_nameFunction;
    00478
    00479     void
    00480     writeName(const XalanDOMChar*   theChars)
    00481     {
    00482         assert(m_nameFunction != 0);
    00483
    00484         (this->*m_nameFunction)(theChars);
    00485     }
    00486
    00487     enum
    00488     {
    00489         kBufferSize = 512       // The size of the buffer
    00490     };
    00491
    00492     static bool
    00493     isContentSpecial(XalanDOMChar   theChar)
    00494     {
    00495         if ((theChar >= kSpecialsSize) || (s_specialChars[theChar] & kContentSpecial))
    00496         {
    00497             return true;
    00498         }
    00499         else
    00500         {
    00501             return false;
    00502         }
    00503     }
    00504
    00505     static bool
    00506     isAttributeSpecial(XalanDOMChar     theChar)
    00507     {
    00508         if ((theChar >= kSpecialsSize) || (s_specialChars[theChar] & kAttributeSpecial))
    00509         {
    00510             return true;
    00511         }
    00512         else
    00513         {
    00514             return false;
    00515         }
    00516     }
    00517
    00518     char                        m_buffer[kBufferSize];
    00519
    00520     char*                       m_bufferPosition;
    00521
    00522     XalanDOMString::size_type   m_bufferRemaining;
    00523 };
    00524
    00525
    00526
    00527 XALAN_CPP_NAMESPACE_END
    00528
    00529
    00530
    00531 #endif  // FORMATTERTOXML_UTF8_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.