Xalan-C++ API Documentation

The Xalan C++ XSLT Processor Version 1.8

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

FormatterToXMLBase.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(FORMATTERTOXMLBASE_HEADER_GUARD_1357924680)
00017 #define FORMATTERTOXMLBASE_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 <vector>
00028 
00029 
00030 
00031 #include <xalanc/XalanDOM/XalanDOMString.hpp>
00032 
00033 
00034 
00035 // Base class header file.
00036 #include <xalanc/PlatformSupport/FormatterListener.hpp>
00037 
00038 
00039 
00040 XALAN_CPP_NAMESPACE_BEGIN
00041 
00042 
00043 
00044 class Writer;
00045 
00046 
00047 
00051 class XALAN_XMLSUPPORT_EXPORT FormatterToXMLBase : public FormatterListener 
00052 {
00053 public:
00054 
00070     FormatterToXMLBase(
00071             Writer&                 writer,
00072             const XalanDOMString&   version,
00073             const XalanDOMString&   mediaType,
00074             const XalanDOMString&   doctypeSystem,
00075             const XalanDOMString&   doctypePublic,
00076             bool                    xmlDecl,
00077             const XalanDOMString&   standalone);
00078 
00079     virtual
00080     ~FormatterToXMLBase();
00081 
00082     // These methods are inherited from FormatterListener ...
00083 
00084     virtual void
00085     setDocumentLocator(const LocatorType* const locator);
00086 
00087     virtual void
00088     startDocument();
00089 
00090     virtual void
00091     endDocument();
00092 
00093     virtual void
00094     startElement(
00095             const XMLCh* const  name,
00096             AttributeListType&  attrs) = 0;
00097 
00098     virtual void
00099     endElement(const XMLCh* const   name) = 0;
00100 
00101     virtual void
00102     characters(
00103             const XMLCh* const  chars,
00104             const unsigned int  length);
00105 
00106     virtual void
00107     charactersRaw(
00108             const XMLCh* const  chars,
00109             const unsigned int  length) = 0;
00110 
00111     virtual void
00112     entityReference(const XMLCh* const  name) = 0;
00113 
00114     virtual void
00115     ignorableWhitespace(
00116             const XMLCh* const  chars,
00117             const unsigned int  length);
00118 
00119     virtual void
00120     processingInstruction(
00121             const XMLCh* const  target,
00122             const XMLCh* const  data);
00123 
00124     virtual void
00125     resetDocument();
00126 
00127     virtual void
00128     comment(const XMLCh* const  data) = 0;
00129 
00130     virtual void
00131     cdata(
00132             const XMLCh* const  ch,
00133             const unsigned int  length);
00134 
00135     virtual Writer*
00136     getWriter() const;
00137 
00138     virtual const XalanDOMString&
00139     getDoctypeSystem() const;
00140 
00141     virtual const XalanDOMString&
00142     getDoctypePublic() const;
00143 
00144     virtual const XalanDOMString&
00145     getEncoding() const = 0;
00146 
00147     virtual const XalanDOMString&
00148     getMediaType() const;
00149 
00150     const XalanDOMString&
00151     getVersion() const
00152     {
00153         return m_version;
00154     }
00155 
00156     const XalanDOMString&
00157     getStandalone() const
00158     {
00159         return m_standalone;
00160     }
00161 
00162     bool
00163     getShouldWriteXMLHeader() const
00164     {
00165         return m_shouldWriteXMLHeader;
00166     }
00167 
00168     void
00169     setShouldWriteXMLHeader(bool    b)
00170     {
00171         m_shouldWriteXMLHeader = b;
00172     }
00173 
00174 #if defined(XALAN_NO_STD_NAMESPACE)
00175 #if defined(XALAN_USE_DEQUE_FOR_VECTOR_BOOL)
00176     typedef deque<bool>         BoolStackType;
00177 #else
00178     typedef vector<bool>        BoolStackType;
00179 #endif
00180 #else
00181 #if defined(XALAN_USE_DEQUE_FOR_VECTOR_BOOL)
00182     typedef std::deque<bool>    BoolStackType;
00183 #else
00184     typedef std::vector<bool>   BoolStackType;
00185 #endif
00186 #endif
00187 
00188 protected:
00189 
00190     virtual void
00191     writeXMLHeader() = 0;
00192 
00193     virtual void
00194     flushBuffer() = 0;
00195 
00196     virtual void
00197     writeDoctypeDecl(const XalanDOMChar*    name) = 0;
00198 
00199     virtual void
00200     writeProcessingInstruction(
00201             const XMLCh*    target,
00202             const XMLCh*    data) = 0;
00203 
00204     virtual void
00205     writeCharacters(
00206             const XMLCh*    chars,
00207             unsigned int    length) = 0;
00208 
00209     virtual void
00210     writeCDATA(
00211             const XMLCh*    chars,
00212             unsigned int    length) = 0;
00213 
00214     virtual void
00215     outputNewline() = 0;
00216 
00225     bool
00226     markParentForChildren()
00227     {
00228         if(!m_elemStack.empty())
00229         {
00230             // See if the parent element has already been flagged as having children.
00231             if(false == m_elemStack.back())
00232             {
00233                 m_elemStack.back() = true;
00234 
00235                 return true;
00236             }
00237         }
00238 
00239         return false;
00240     }
00241 
00245     void
00246     openElementForChildren()
00247     {
00248         m_elemStack.push_back(false);
00249     }
00250 
00251     bool
00252     outsideDocumentElement() const
00253     {
00254         return m_elemStack.empty();
00255     }
00256 
00262     bool
00263     childNodesWereAdded()
00264     {
00265         bool    fResult = false;
00266 
00267         if (m_elemStack.empty() == false)
00268         {
00269             fResult = m_elemStack.back();
00270 
00271             m_elemStack.pop_back();
00272         }
00273 
00274         return fResult;
00275     }
00276 
00277     void
00278     generateDoctypeDecl(const XalanDOMChar*     name)
00279     {
00280         if(true == m_needToOutputDoctypeDecl)          
00281         {
00282             assert(m_doctypeSystem.empty() == false);
00283 
00284             writeDoctypeDecl(name);
00285 
00286             m_needToOutputDoctypeDecl = false;
00287         }
00288     }
00289 
00293     Writer*                 m_writer;
00294 
00295     void
00296     flushWriter();
00297 
00301     bool        m_nextIsRaw;
00302 
00306     bool        m_spaceBeforeClose;
00307 
00311     const XalanDOMString    m_doctypeSystem;
00312 
00316     const XalanDOMString    m_doctypePublic;
00317 
00321     const XalanDOMString    m_version;
00322 
00326     const XalanDOMString    m_standalone;
00327 
00331     const XalanDOMString    m_mediaType;
00332 
00336     const XalanDOMChar*     m_newlineString;
00337 
00341     XalanDOMString::size_type   m_newlineStringLength;
00342 
00343     static bool
00344     isUTF16HighSurrogate(XalanDOMChar   theChar)
00345     {
00346         return 0xD800u <= theChar && theChar <= 0xDBFFu ? true : false;
00347     }
00348 
00349     static bool
00350     isUTF16LowSurrogate(XalanDOMChar    theChar)
00351     {
00352         return 0xDC00u <= theChar && theChar <= 0xDFFFu ? true : false;
00353     }
00354 
00355     static unsigned int
00356     decodeUTF16SurrogatePair(
00357             XalanDOMChar    theHighSurrogate,
00358             XalanDOMChar    theLowSurrogate);
00359 
00365     static void
00366     throwInvalidUTF16SurrogateException(XalanDOMChar    ch);
00367 
00374     static void
00375     throwInvalidUTF16SurrogateException(
00376             XalanDOMChar    ch,
00377             XalanDOMChar    next);
00378 
00385     static void
00386     throwInvalidCharacterException(unsigned int     ch);
00387 
00388     enum
00389     {
00390             kNotSpecial = 0,
00391             kContentSpecial = 1,    // A flag to indicate a value in s_specialChars applies to content
00392             kAttributeSpecial = 2,  // A flag to indicate a value in s_specialChars applies to attributes
00393             kBothSpecial = 3,       // A flag t0 indicate a value in s_specialChars applies to both content and attributes
00394             kSpecialsSize = 0x80,   // The size of s_specialChars
00395             kBufferSize = 512       // The size of the buffer
00396     };
00397 
00398     static const XalanDOMChar   s_specialChars[];
00399 
00400 private:
00401 
00402     // These are not implemented.
00403     FormatterToXMLBase(const FormatterToXMLBase&);
00404 
00405     FormatterToXMLBase&
00406     operator=(const FormatterToXMLBase&);
00407 
00408     bool
00409     operator==(const FormatterToXMLBase&) const;
00410 
00411     // Data members...
00417     bool        m_needToOutputDoctypeDecl;
00418 
00422     bool        m_shouldWriteXMLHeader;
00423 
00428     BoolStackType   m_elemStack;
00429 
00433     static const XalanDOMChar               s_xhtmlDocTypeString[];
00434 
00435     static const XalanDOMString::size_type  s_xhtmlDocTypeStringLength;
00436 };
00437 
00438 
00439 
00440 XALAN_CPP_NAMESPACE_END
00441 
00442 
00443 
00444 #endif  // FORMATTERTOXMLBASE_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.8
Copyright © 1999-2004 The Apache Software Foundation. All Rights Reserved.