## Xalan-C++ API Documentation

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

Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

# FormatterToXML_UTF8.hpp

Go to the documentation of this file.

    00001 /*
    00002  * Copyright 1999-2004 The Apache Software Foundation.
    00003  *
    00004  * Licensed under the Apache License, Version 2.0 (the "License");
    00005  * you may not use this file except in compliance with the License.
    00006  * You may obtain a copy of the License at
    00007  *
    00008  *     http://www.apache.org/licenses/LICENSE-2.0
    00009  *
    00010  * Unless required by applicable law or agreed to in writing, software
    00011  * distributed under the License is distributed on an "AS IS" BASIS,
    00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    00013  * See the License for the specific language governing permissions and
    00014  * limitations under the License.
    00015  */
    00016 #if !defined(FORMATTERTOXML_UTF8_HEADER_GUARD_1357924680)
    00017 #define FORMATTERTOXML_UTF8_HEADER_GUARD_1357924680
    00018
    00019
    00020
    00021
    00022 // Base include file.  Must be first.
    00023 #include <xalanc/XMLSupport/XMLSupportDefinitions.hpp>
    00024
    00025
    00026
    00027 #include <xalanc/XalanDOM/XalanDOMString.hpp>
    00028
    00029
    00030
    00031 // Base class header file.
    00032 #include "FormatterToXMLBase.hpp"
    00033
    00034
    00035
    00036 XALAN_CPP_NAMESPACE_BEGIN
    00037
    00038
    00039
    00043 class XALAN_XMLSUPPORT_EXPORT FormatterToXML_UTF8 : public FormatterToXMLBase
    00044 {
    00045 public:
    00046
    00050     static void
    00051     initialize(MemoryManagerType& theManager);
    00052
    00056     static void
    00057     terminate();
    00058
    00074     FormatterToXML_UTF8(
    00075             Writer&                 writer,
    00076             const XalanDOMString&   version = XalanDOMString(XalanMemMgrs::getDummyMemMgr()),
    00077             const XalanDOMString&   mediaType = XalanDOMString(XalanMemMgrs::getDummyMemMgr()),
    00078             const XalanDOMString&   doctypeSystem = XalanDOMString(XalanMemMgrs::getDummyMemMgr()),
    00079             const XalanDOMString&   doctypePublic = XalanDOMString(XalanMemMgrs::getDummyMemMgr()),
    00080             bool                    xmlDecl = true,
    00081             const XalanDOMString&   standalone = XalanDOMString(XalanMemMgrs::getDummyMemMgr()),
    00082             MemoryManagerType&      theManager XALAN_DEFAULT_MEMMGR);
    00083
    00084     static FormatterToXML_UTF8*
    00085     create(
    00086             MemoryManagerType&      theManager,
    00087             Writer&                 writer,
    00088             const XalanDOMString&   version = XalanDOMString(XalanMemMgrs::getDummyMemMgr()),
    00089             const XalanDOMString&   mediaType = XalanDOMString(XalanMemMgrs::getDummyMemMgr()),
    00090             const XalanDOMString&   doctypeSystem = XalanDOMString(XalanMemMgrs::getDummyMemMgr()),
    00091             const XalanDOMString&   doctypePublic = XalanDOMString(XalanMemMgrs::getDummyMemMgr()),
    00092             bool                    xmlDecl = true,
    00093             const XalanDOMString&   standalone = XalanDOMString(XalanMemMgrs::getDummyMemMgr()));
    00094
    00095     virtual
    00096     ~FormatterToXML_UTF8();
    00097
    00098
    00099     // These methods are inherited from FormatterListener ...
    00100
    00101     virtual void
    00102     startElement(
    00103             const XMLCh* const  name,
    00104             AttributeListType&  attrs);
    00105
    00106     virtual void
    00107     endElement(const XMLCh* const   name);
    00108
    00109     virtual void
    00110     charactersRaw(
    00111             const XMLCh* const  chars,
    00112             const unsigned int  length);
    00113
    00114     virtual void
    00115     entityReference(const XMLCh* const  name);
    00116
    00117     virtual void
    00118     comment(const XMLCh* const  data);
    00119
    00120     virtual const XalanDOMString&
    00121     getEncoding() const;
    00122
    00123 protected:
    00124
    00125     virtual void
    00126     writeXMLHeader();
    00127
    00128     virtual void
    00129     flushBuffer();
    00130
    00131     virtual void
    00132     writeDoctypeDecl(const XalanDOMChar*    name);
    00133
    00134     virtual void
    00135     writeProcessingInstruction(
    00136             const XMLCh*    target,
    00137             const XMLCh*    data);
    00138
    00139     virtual void
    00140     writeCharacters(
    00141             const XMLCh*    chars,
    00142             unsigned int    length);
    00143
    00144     virtual void
    00145     writeCDATA(
    00146             const XMLCh*    chars,
    00147             unsigned int    length);
    00148
    00152     virtual void
    00153     outputNewline();
    00154
    00158     XalanDOMString::size_type
    00159     writeDefaultEscape(
    00160             XalanDOMChar                ch,
    00161             XalanDOMString::size_type   i,
    00162             const XalanDOMChar          chars[],
    00163             XalanDOMString::size_type   len);
    00164
    00168     XalanDOMString::size_type
    00169     writeDefaultAttributeEscape(
    00170             XalanDOMChar                ch,
    00171             XalanDOMString::size_type   i,
    00172             const XalanDOMChar          chars[],
    00173             XalanDOMString::size_type   len);
    00174
    00179     bool
    00180     writeDefaultEntity(XalanDOMChar     ch);
    00181
    00186     bool
    00187     writeDefaultAttributeEntity(XalanDOMChar    ch);
    00188
    00193     void
    00194     writeCommentData(const XalanDOMChar*    data);
    00195
    00200     void
    00201     writeParentTagEnd();
    00202
    00209     XalanDOMString::size_type
    00210     writeNormalizedChar(
    00211             XalanDOMChar                ch,
    00212             const XalanDOMChar          chars[],
    00213             XalanDOMString::size_type   start,
    00214             XalanDOMString::size_type   length);
    00215
    00222     void
    00223     writeCDATAChars(
    00224             const XalanDOMChar          ch[],
    00225             XalanDOMString::size_type   length);
    00226
    00233     void
    00234     writeAttrString(
    00235             const XalanDOMChar*         theString,
    00236             XalanDOMString::size_type   theStringLength);
    00237
    00238 private:
    00239
    00240     // These are not implemented.
    00241     FormatterToXML_UTF8(const FormatterToXML_UTF8&);
    00242
    00243     FormatterToXML_UTF8&
    00244     operator=(const FormatterToXML_UTF8&);
    00245
    00246     bool
    00247     operator==(const FormatterToXML_UTF8&) const;
    00248
    00249     void
    00250     safeWriteContent(
    00251             const XalanDOMChar*         theChars,
    00252             XalanDOMString::size_type   theLength);
    00253
    00254     void
    00255     write(
    00256             const XalanDOMChar*         theChars,
    00257             XalanDOMString::size_type   theLength);
    00258
    00259     void
    00260     writeName1_0(const XalanDOMChar*    theChars);
    00261
    00262     void
    00263     writeName1_1(const XalanDOMChar*    theChars);
    00264
    00265     void
    00266     write(const XalanDOMChar*   theChars)
    00267     {
    00268         write(theChars, XalanDOMString::length(theChars));
    00269     }
    00270
    00271     void
    00272     write(XalanDOMChar  theChar)
    00273     {
    00274         write((unsigned int)theChar);
    00275     }
    00276
    00277     void
    00278     write(unsigned int  theChar);
    00279
    00280     void
    00281     write(const XalanDOMString&     theChars)
    00282     {
    00283         write(theChars.c_str(), theChars.length());
    00284     }
    00285
    00286     void
    00287     write(char  theChar);
    00288
    00289     void
    00290     write(
    00291             const char*                 theChars,
    00292             XalanDOMString::size_type   theLength);
    00293
    00294     void
    00295     write(const char*   theChars)
    00296     {
    00297         write(theChars, XalanDOMString::length(theChars));
    00298     }
    00299
    00305     void
    00306     processAttribute(
    00307             const XalanDOMChar*     name,
    00308             const XalanDOMChar*     value);
    00309
    00315     void
    00316     writeNormalizedPIData(
    00317             const XalanDOMChar*         theData,
    00318             XalanDOMString::size_type   theLength);
    00319
    00320     // Data members...
    00324     static const XalanDOMString&    s_utf8String;
    00325
    00329     static const char                       s_doctypeHeaderStartString[];
    00330
    00331     static const XalanDOMString::size_type  s_doctypeHeaderStartStringLength;
    00332
    00336     static const char                       s_doctypeHeaderPublicString[];
    00337
    00338     static const XalanDOMString::size_type  s_doctypeHeaderPublicStringLength;
    00339
    00343     static const char                       s_doctypeHeaderSystemString[];
    00344
    00345     static const XalanDOMString::size_type  s_doctypeHeaderSystemStringLength;
    00346
    00350     static const char                       s_xmlHeaderStartString[];
    00351
    00352     static const XalanDOMString::size_type  s_xmlHeaderStartStringLength;
    00353
    00357     static const char                       s_xmlHeaderEncodingString[];
    00358
    00359     static const XalanDOMString::size_type  s_xmlHeaderEncodingStringLength;
    00360
    00364     static const char                       s_xmlHeaderStandaloneString[];
    00365
    00366     static const XalanDOMString::size_type  s_xmlHeaderStandaloneStringLength;
    00367
    00371     static const char                       s_xmlHeaderEndString[];
    00372
    00373     static const XalanDOMString::size_type  s_xmlHeaderEndStringLength;
    00374
    00378     static const char                       s_defaultVersionString[];
    00379
    00380     static const XalanDOMString::size_type  s_defaultVersionStringLength;
    00381
    00385     static const XalanDOMChar               s_xhtmlDocTypeString[];
    00386
    00387     static const XalanDOMString::size_type  s_xhtmlDocTypeStringLength;
    00388
    00392     static const char                       s_cdataOpenString[];
    00393
    00394     static const XalanDOMString::size_type  s_cdataOpenStringLength;
    00395
    00399     static const char                       s_cdataCloseString[];
    00400
    00401     static const XalanDOMString::size_type  s_cdataCloseStringLength;
    00402
    00406     static const char                       s_lessThanEntityString[];
    00407
    00408     static const XalanDOMString::size_type  s_lessThanEntityStringLength;
    00409
    00413     static const char                       s_greaterThanEntityString[];
    00414
    00415     static const XalanDOMString::size_type  s_greaterThanEntityStringLength;
    00416
    00420     static const char                       s_ampersandEntityString[];
    00421
    00422     static const XalanDOMString::size_type  s_ampersandEntityStringLength;
    00423
    00427     static const char                       s_quoteEntityString[];
    00428
    00429     static const XalanDOMString::size_type  s_quoteEntityStringLength;
    00430
    00434     static const char                       s_linefeedNCRString[];
    00435
    00436     static const XalanDOMString::size_type  s_linefeedNCRStringLength;
    00437
    00441     static const char                       s_carriageReturnNCRString[];
    00442
    00443     static const XalanDOMString::size_type  s_carriageReturnNCRStringLength;
    00444
    00448     static const char                       s_htabNCRString[];
    00449
    00450     static const XalanDOMString::size_type  s_htabNCRStringLength;
    00451
    00452
    00453     typedef void (FormatterToXML_UTF8::*NameFunctionType)(const XalanDOMChar*);
    00454
    00455     NameFunctionType    m_nameFunction;
    00456
    00457     void
    00458     writeName(const XalanDOMChar*   theChars)
    00459     {
    00460         assert(m_nameFunction != 0);
    00461
    00462         (this->*m_nameFunction)(theChars);
    00463     }
    00464
    00465     enum
    00466     {
    00467         kBufferSize = 512       // The size of the buffer
    00468     };
    00469
    00470     static bool
    00471     isContentSpecial(XalanDOMChar   theChar)
    00472     {
    00473         if ((theChar >= kSpecialsSize) || (s_specialChars[theChar] & kContentSpecial))
    00474         {
    00475             return true;
    00476         }
    00477         else
    00478         {
    00479             return false;
    00480         }
    00481     }
    00482
    00483     static bool
    00484     isAttributeSpecial(XalanDOMChar     theChar)
    00485     {
    00486         if ((theChar >= kSpecialsSize) || (s_specialChars[theChar] & kAttributeSpecial))
    00487         {
    00488             return true;
    00489         }
    00490         else
    00491         {
    00492             return false;
    00493         }
    00494     }
    00495
    00496     char                        m_buffer[kBufferSize];
    00497
    00498     char*                       m_bufferPosition;
    00499
    00500     XalanDOMString::size_type   m_bufferRemaining;
    00501 };
    00502
    00503
    00504
    00505 XALAN_CPP_NAMESPACE_END
    00506
    00507
    00508
    00509 #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.9 Copyright © 1999-2004 The Apache Software Foundation. All Rights Reserved.