## Xalan-C++ API Documentation

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

Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members File Members

# FormatterToXML Class Reference

FormatterToXML formats SAX-style events into XML. More...

`#include <FormatterToXML.hpp>`

Inheritance diagram for FormatterToXML:

[legend]
Collaboration diagram for FormatterToXML:

[legend]
List of all members.

## Public Types

- typedef XalanVector<bool> BoolStackType
- typedef XalanVector<XalanDOMChar> DOMCharBufferType
- typedef XalanVector<char> ByteBufferType
- enum eDummy { eDefaultIndentAmount = 0 }

## Public Methods

- FormatterToXML (Writer &writer, const XalanDOMString &version=XalanDOMString(XalanMemMgrs::getDummyMemMgr()), bool doIndent=false, int indent=eDefaultIndentAmount, const XalanDOMString &encoding=XalanDOMString(XalanMemMgrs::getDummyMemMgr()), const XalanDOMString &mediaType=XalanDOMString(XalanMemMgrs::getDummyMemMgr()), const XalanDOMString &doctypeSystem=XalanDOMString(XalanMemMgrs::getDummyMemMgr()), const XalanDOMString &doctypePublic=XalanDOMString(XalanMemMgrs::getDummyMemMgr()), bool xmlDecl=true, const XalanDOMString &standalone=XalanDOMString(XalanMemMgrs::getDummyMemMgr()), eFormat format=OUTPUT_METHOD_XML, bool fBufferData=true, MemoryManagerType &theManager XALAN_DEFAULT_MEMMGR)
    Constructor for customized encoding and doctype. More...
- virtual ~FormatterToXML ()
- MemoryManagerType& getMemoryManager ()
- virtual void setDocumentLocator (const LocatorType *const locator)
- virtual void startDocument ()
- virtual void endDocument ()
- virtual void startElement (const XMLCh *const name, AttributeListType &attrs)
- virtual void endElement (const XMLCh *const name)
- virtual void characters (const XMLCh *const chars, const unsigned int length)
- virtual void charactersRaw (const XMLCh *const chars, const unsigned int length)
- virtual void entityReference (const XMLCh *const name)
- virtual void ignorableWhitespace (const XMLCh *const chars, const unsigned int length)
- virtual void processingInstruction (const XMLCh *const target, const XMLCh *const data)
- virtual void resetDocument ()
- virtual void comment (const XMLCh *const data)
- virtual void cdata (const XMLCh *const ch, const unsigned int length)
- virtual Writer* getWriter () const
- virtual const XalanDOMString& getDoctypeSystem () const
- virtual const XalanDOMString& getDoctypePublic () const
- virtual const XalanDOMString& getEncoding () const
- virtual const XalanDOMString& getMediaType () const
- virtual int getIndent () const
- const XalanDOMString& getVersion () const
- const XalanDOMString& getStandalone () const
- bool getShouldWriteXMLHeader () const
- void setShouldWriteXMLHeader (bool b)
- bool getStripCData () const
- void setStripCData (bool b)
- bool getEscapeCData () const
- void setEscapeCData (bool b)
- bool getDoIndent () const
- void setDoIndent (bool value)
- void setIndent (int value)

## Static Public Methods

- FormatterToXML* create (MemoryManagerType &theManager, Writer &writer, const XalanDOMString &version=XalanDOMString(XalanMemMgrs::getDummyMemMgr()), bool doIndent=false, int indent=eDefaultIndentAmount, const XalanDOMString &encoding=XalanDOMString(XalanMemMgrs::getDummyMemMgr()), const XalanDOMString &mediaType=XalanDOMString(XalanMemMgrs::getDummyMemMgr()), const XalanDOMString &doctypeSystem=XalanDOMString(XalanMemMgrs::getDummyMemMgr()), const XalanDOMString &doctypePublic=XalanDOMString(XalanMemMgrs::getDummyMemMgr()), bool xmlDecl=true, const XalanDOMString &standalone=XalanDOMString(XalanMemMgrs::getDummyMemMgr()), eFormat format=OUTPUT_METHOD_XML, bool fBufferData=true)

## Protected Types

- typedef void (FormatterToXML::* AccumCharFunctionType )(XalanDOMChar)
- typedef void (FormatterToXML::* AccumStringFunctionType )(const XalanDOMChar *)
- typedef void (FormatterToXML::* AccumDOMStringFunctionType )(const XalanDOMString &)
- typedef void (FormatterToXML::* AccumArrayFunctionType )(const XalanDOMChar[], XalanDOMString::size_type, XalanDOMString::size_type)
- typedef void (FormatterToXML::* FlushFunctionType )()
- enum eDummyTwo { SPECIALSSIZE = 256 }

## Protected Methods

- void outputLineSep ()
    Output a line break. More...
- void accumName (XalanDOMChar ch)
    Append a wide character to the buffer. More...
- void accumContent (XalanDOMChar ch)
    Append a wide character to the buffer. More...
- void accumName (const XalanDOMChar *chars)
    Append a null-terminated array of wide characters to the buffer. More...
- void accumContent (const XalanDOMChar *chars)
    Append a null-terminated array of wide characters to the buffer. More...
- void accumName (const XalanDOMChar chars[], XalanDOMString::size_type start, XalanDOMString::size_type length)
    Append an array of wide character to the buffer. More...
- void accumContent (const XalanDOMChar chars[], XalanDOMString::size_type start, XalanDOMString::size_type length)
    Append an array of wide character to the buffer. More...
- void accumName (const XalanDOMString &str)
    Append a string to the buffer. More...
- void accumContent (const XalanDOMString &str)
    Append a string to the buffer. More...
- XalanDOMString::size_type accumDefaultEscape (XalanDOMChar ch, XalanDOMString::size_type i, const XalanDOMChar chars[], XalanDOMString::size_type len, bool escLF)
    Escape and accum a character. More...
- virtual bool accumDefaultEntity (XalanDOMChar ch, bool escLF)
    Handle one of the default entities, return false if it is not a default entity. More...
- void initAttrCharsMap ()
    Set the attribute characters what will require special mapping. More...
- void initCharsMap ()
    Set the output characters what will require special mapping. More...
- void flushChars ()
    Flush the char buffer. More...
- void flushBytes ()
    Flush the byte buffer. More...
- void flushWriter ()
- void openElementForChildren ()
- bool childNodesWereAdded ()
- bool shouldIndent () const
- void writeParentTagEnd ()
    Check to see if a parent's ">" has been written, and, if it has not, write it. More...
- void indent (int n)
    Prints a newline character and n spaces. More...
- virtual void writeNormalizedChars (const XalanDOMChar ch[], XalanDOMString::size_type start, XalanDOMString::size_type length, bool isCData)
    Write normalized characters to the writer. More...
- void writeNumberedEntityReference (unsigned long theNumber)
    Write a number into the buffer as an entity reference. More...
- virtual void writeAttrString (const XalanDOMChar *theString, XalanDOMString::size_type theStringLength)
    Write an attribute string. More...
- virtual void accumCommentData (const XalanDOMChar *data)
    Write the data for a comment. More...

## Static Protected Methods

- void throwInvalidUTF16SurrogateException (XalanDOMChar ch, MemoryManagerType &theManager)
    Throw an exception when an invalid surrogate is encountered. More...
- void throwInvalidUTF16SurrogateException (XalanDOMChar ch, XalanDOMChar next, MemoryManagerType &theManager)
    Throw an exception when an invalid surrogate is encountered. More...
- void throwInvalidCharacterException (unsigned int ch, MemoryManagerType &theManager)
    Throw an exception when an invalid XML character is encountered. More...
- bool isUTF16Surrogate (XalanDOMChar ch)

## Protected Attributes

- Writer* const m_writer
    The writer where the XML will be written. More...
- XalanOutputStream* const m_stream
    The stream where the XML will be written. More...
- XalanDOMChar m_maxCharacter
    The maximum character size before we have to resort to escaping. More...
- XalanDOMChar m_attrCharsMap [SPECIALSSIZE]
- XalanDOMChar m_charsMap [SPECIALSSIZE]
- bool m_shouldWriteXMLHeader
    If true, XML header should be written to output. More...
- bool m_ispreserve
    State flag to tell if preservation of whitespace is important. More...
- bool m_doIndent
    Flag to tell if indenting (pretty-printing) is on. More...
- bool m_startNewLine
    Flag to signal that a newline should be added. More...
- bool m_needToOutputDocTypeDecl
    Flag to tell that we need to add the doctype decl, which we can't do until the first element is encountered. More...
- bool m_isprevtext
    State flag that tells if the previous node processed was text, so we can tell if we should preserve whitespace. More...
- bool m_stripCData
    If true, cdata sections are simply stripped of their CDATA brackets, without escaping. More...
- bool m_nextIsRaw
    Tell if the next text should be raw. More...
- bool m_inCData
    Tells if we're in CData section. More...
- bool m_encodingIsUTF
    Flag to quickly tell if the encoding is capable of full Unicode support. More...
- const XalanDOMString m_doctypeSystem
    The System ID for the doc type. More...
- const XalanDOMString m_doctypePublic
    The public ID for the doc type. More...
- XalanDOMString m_encoding
    The character encoding. More...
- int m_currentIndent
    Flag to keep track of the indent amount. More...
- int m_indent
    Amount to indent. More...
- BoolStackType m_preserves
    Stack to keep track of whether or not we need to preserve whitespace. More...
- XalanDOMString m_stringBuffer

## Detailed Description

FormatterToXML formats SAX-style events into XML.

## Member Typedef Documentation

typedef void(FormatterToXML::* FormatterToXML::AccumArrayFunctionType)(const XalanDOMChar[], XalanDOMString::size_type, XalanDOMString::size_type)`[protected]`

typedef void(FormatterToXML::* FormatterToXML::AccumCharFunctionType)(XalanDOMChar)`[protected]`

typedef void(FormatterToXML::* FormatterToXML::AccumDOMStringFunctionType)(const XalanDOMString &)`[protected]`

typedef void(FormatterToXML::* FormatterToXML::AccumStringFunctionType)(const XalanDOMChar *)`[protected]`

typedef XalanVector< bool > FormatterToXML::BoolStackType<bool>

typedef XalanVector< char > FormatterToXML::ByteBufferType<char>

typedef XalanVector< XalanDOMChar > FormatterToXML::DOMCharBufferType<XalanDOMChar>

typedef void(FormatterToXML::* FormatterToXML::FlushFunctionType)()`[protected]`

## Member Enumeration Documentation

enum FormatterToXML::eDummy

  | Enumeration values:
  eDefaultIndentAmount |

enum FormatterToXML::eDummyTwo`[protected]`

  | Enumeration values:
  SPECIALSSIZE |

## Constructor & Destructor Documentation

FormatterToXML::FormatterToXML ( | Writer & writer,
| const XalanDOMString & version = XalanDOMString(XalanMemMgrs::getDummyMemMgr()),
| bool doIndent = false,
| int indent = eDefaultIndentAmount,
| const XalanDOMString & encoding = XalanDOMString(XalanMemMgrs::getDummyMemMgr()),
| const XalanDOMString & mediaType = XalanDOMString(XalanMemMgrs::getDummyMemMgr()),
| const XalanDOMString & doctypeSystem = XalanDOMString(XalanMemMgrs::getDummyMemMgr()),
| const XalanDOMString & doctypePublic = XalanDOMString(XalanMemMgrs::getDummyMemMgr()),
| bool xmlDecl = true,
| const XalanDOMString & standalone = XalanDOMString(XalanMemMgrs::getDummyMemMgr()),
| eFormat format = OUTPUT_METHOD_XML,
| bool fBufferData = true,
| MemoryManagerType &theManager XALAN_DEFAULT_MEMMGR )

  | Constructor for customized encoding and doctype. Parameters:
  writer | character output stream to use
  version | version of the output method
  doIndent | true if output is to be indented
  indent | number of spaces to indent at each nesting level
  encoding | character encoding in use by writer
  mediaType | media type (MIME content type) of the data
  doctypeSystem | system identifier to be used in the document type declaration
  doctypePublic | public identifier to be used in the document type declaration
  xmlDecl | true if the XSLT processor should output an XML declaration
  standalone | true if the XSLT processor should output a standalone document declaration
  format | should be used only by derived classes.
  fBufferData | If true, data will be buffered in the formatter

FormatterToXML::~FormatterToXML ( | )`[virtual]`

## Member Function Documentation

void FormatterToXML::accumCommentData ( | const XalanDOMChar * data )`[protected, virtual]`

  | Write the data for a comment. Parameters:
  data | The comment's data.
Reimplemented in FormatterToHTML.

void FormatterToXML::accumContent ( | const XalanDOMString & str )`[protected]`

  | Append a string to the buffer. Parameters:
  str | the string to append

void FormatterToXML::accumContent ( | const XalanDOMChar chars[],
| XalanDOMString::size_type start,
| XalanDOMString::size_type length )`[protected]`

| Append an array of wide character to the buffer. @chars the array to append @start the offset into the array to start from @length the number of characters to append

void FormatterToXML::accumContent ( | const XalanDOMChar * chars )`[protected]`

| Append a null-terminated array of wide characters to the buffer. @chars the array to append

void FormatterToXML::accumContent ( | XalanDOMChar ch )`[protected]`

| Append a wide character to the buffer. @ch the character to append.

bool FormatterToXML::accumDefaultEntity ( | XalanDOMChar ch,
| bool escLF )`[protected, virtual]`

| Handle one of the default entities, return false if it is not a default entity. Reimplemented in FormatterToHTML.

XalanDOMString::size_type FormatterToXML::accumDefaultEscape ( | XalanDOMChar ch,
| XalanDOMString::size_type i,
| const XalanDOMChar chars[],
| XalanDOMString::size_type len,
| bool escLF )`[protected]`

| Escape and accum a character.

void FormatterToXML::accumName ( | const XalanDOMString & str )`[protected]`

  | Append a string to the buffer. Characters that are not representable in the encoding are not written as entities. Parameters:
  str | the string to append

void FormatterToXML::accumName ( | const XalanDOMChar chars[],
| XalanDOMString::size_type start,
| XalanDOMString::size_type length )`[protected]`

| Append an array of wide character to the buffer. Characters that are not representable in the encoding are not written as entities. @chars the array to append @start the offset into the array to start from @length the number of characters to append

void FormatterToXML::accumName ( | const XalanDOMChar * chars )`[protected]`

| Append a null-terminated array of wide characters to the buffer. Characters that are not representable in the encoding are not written as entities. @chars the array to append

void FormatterToXML::accumName ( | XalanDOMChar ch )`[protected]`

| Append a wide character to the buffer. Characters that are not representable in the encoding are not written as entities. @ch the character to append.

void FormatterToXML::cdata ( | const XMLCh *const ch,
| const unsigned int length )`[virtual]`

| Reimplemented in FormatterToHTML.

void FormatterToXML::characters ( | const XMLCh *const chars,
| const unsigned int length )`[virtual]`

| Reimplemented in FormatterToHTML.

void FormatterToXML::charactersRaw ( | const XMLCh *const chars,
| const unsigned int length )`[virtual]`

bool FormatterToXML::childNodesWereAdded ( | )`[protected]`

void FormatterToXML::comment ( | const XMLCh *const data )`[virtual]`

FormatterToXML * FormatterToXML::create ( | MemoryManagerType & theManager,
| Writer & writer,
| const XalanDOMString & version = XalanDOMString(XalanMemMgrs::getDummyMemMgr()),
| bool doIndent = false,
| int indent = eDefaultIndentAmount,
| const XalanDOMString & encoding = XalanDOMString(XalanMemMgrs::getDummyMemMgr()),
| const XalanDOMString & mediaType = XalanDOMString(XalanMemMgrs::getDummyMemMgr()),
| const XalanDOMString & doctypeSystem = XalanDOMString(XalanMemMgrs::getDummyMemMgr()),
| const XalanDOMString & doctypePublic = XalanDOMString(XalanMemMgrs::getDummyMemMgr()),
| bool xmlDecl = true,
| const XalanDOMString & standalone = XalanDOMString(XalanMemMgrs::getDummyMemMgr()),
| eFormat format = OUTPUT_METHOD_XML,
| bool fBufferData = true )`[static]`

void FormatterToXML::endDocument ( | )`[virtual]`

| Reimplemented in FormatterToHTML.

void FormatterToXML::endElement ( | const XMLCh *const name )`[virtual]`

| Reimplemented in FormatterToHTML.

void FormatterToXML::entityReference ( | const XMLCh *const name )`[virtual]`

| Reimplemented in FormatterToHTML.

void FormatterToXML::flushBytes ( | )`[protected]`

| Flush the byte buffer.

void FormatterToXML::flushChars ( | )`[protected]`

| Flush the char buffer.

void FormatterToXML::flushWriter ( | )`[protected]`

bool FormatterToXML::getDoIndent ( | ) const

const XalanDOMString & FormatterToXML::getDoctypePublic ( | ) const`[virtual]`

const XalanDOMString & FormatterToXML::getDoctypeSystem ( | ) const`[virtual]`

const XalanDOMString & FormatterToXML::getEncoding ( | ) const`[virtual]`

bool FormatterToXML::getEscapeCData ( | ) const

int FormatterToXML::getIndent ( | ) const`[virtual]`

const XalanDOMString & FormatterToXML::getMediaType ( | ) const`[virtual]`

MemoryManagerType & FormatterToXML::getMemoryManager ( | )

bool FormatterToXML::getShouldWriteXMLHeader ( | ) const

const XalanDOMString & FormatterToXML::getStandalone ( | ) const

bool FormatterToXML::getStripCData ( | ) const

const XalanDOMString & FormatterToXML::getVersion ( | ) const

Writer * FormatterToXML::getWriter ( | ) const`[virtual]`

void FormatterToXML::ignorableWhitespace ( | const XMLCh *const chars,
| const unsigned int length )`[virtual]`

void FormatterToXML::indent ( | int n )`[protected]`

  | Prints a newline character and n spaces. Parameters:
  n | Number of spaces to print.

void FormatterToXML::initAttrCharsMap ( | )`[protected]`

| Set the attribute characters what will require special mapping.

void FormatterToXML::initCharsMap ( | )`[protected]`

| Set the output characters what will require special mapping.

bool FormatterToXML::isUTF16Surrogate ( | XalanDOMChar ch )`[static, protected]`

void FormatterToXML::openElementForChildren ( | )`[protected]`

void FormatterToXML::outputLineSep ( | )`[protected]`

| Output a line break.

void FormatterToXML::processingInstruction ( | const XMLCh *const target,
| const XMLCh *const data )`[virtual]`

| Reimplemented in FormatterToHTML.

void FormatterToXML::resetDocument ( | )`[virtual]`

void FormatterToXML::setDoIndent ( | bool value )

void FormatterToXML::setDocumentLocator ( | const LocatorType *const locator )`[virtual]`

void FormatterToXML::setEscapeCData ( | bool b )

void FormatterToXML::setIndent ( | int value )

void FormatterToXML::setShouldWriteXMLHeader ( | bool b )

void FormatterToXML::setStripCData ( | bool b )

bool FormatterToXML::shouldIndent ( | ) const`[protected]`

void FormatterToXML::startDocument ( | )`[virtual]`

| Reimplemented in FormatterToHTML.

void FormatterToXML::startElement ( | const XMLCh *const name,
| AttributeListType & attrs )`[virtual]`

| Reimplemented in FormatterToHTML.

void FormatterToXML::throwInvalidCharacterException ( | unsigned int ch,
| MemoryManagerType & theManager )`[static, protected]`

  | Throw an exception when an invalid XML character is encountered. Parameters:
  ch | The first character in the surrogate
  next | The next character in the surrogate

void FormatterToXML::throwInvalidUTF16SurrogateException ( | XalanDOMChar ch,
| XalanDOMChar next,
| MemoryManagerType & theManager )`[static, protected]`

  | Throw an exception when an invalid surrogate is encountered. Parameters:
  ch | The first character in the surrogate
  next | The next character in the surrogate
  theManager | The MemoryManager instance to use

void FormatterToXML::throwInvalidUTF16SurrogateException ( | XalanDOMChar ch,
| MemoryManagerType & theManager )`[static, protected]`

  | Throw an exception when an invalid surrogate is encountered. Parameters:
  ch | The first character in the surrogate
  theManager | The MemoryManager instance to use

void FormatterToXML::writeAttrString ( | const XalanDOMChar * theString,
| XalanDOMString::size_type theStringLength )`[protected, virtual]`

  | Write an attribute string. Parameters:
  theString | The string to write.
  theStringLength | The length of the string.
Reimplemented in FormatterToHTML.

void FormatterToXML::writeNormalizedChars ( | const XalanDOMChar ch[],
| XalanDOMString::size_type start,
| XalanDOMString::size_type length,
| bool isCData )`[protected, virtual]`

  | Write normalized characters to the writer. Parameters:
  ch | the string to write.
  start | the start offset into the string.
  length | the length of the string.
  isCData | true if writing CDATA.

void FormatterToXML::writeNumberedEntityReference ( | unsigned long theNumber )`[protected]`

  | Write a number into the buffer as an entity reference. Parameters:
  theNumber | the number to write.

void FormatterToXML::writeParentTagEnd ( | )`[protected]`

| Check to see if a parent's ">" has been written, and, if it has not, write it.

## Member Data Documentation

XalanDOMChar FormatterToXML::m_attrCharsMap`[protected]`

XalanDOMChar FormatterToXML::m_charsMap`[protected]`

int FormatterToXML::m_currentIndent`[protected]`

| Flag to keep track of the indent amount.

bool FormatterToXML::m_doIndent`[protected]`

| Flag to tell if indenting (pretty-printing) is on.

const XalanDOMString FormatterToXML::m_doctypePublic`[protected]`

| The public ID for the doc type.

const XalanDOMString FormatterToXML::m_doctypeSystem`[protected]`

| The System ID for the doc type.

XalanDOMString FormatterToXML::m_encoding`[protected]`

| The character encoding.

bool FormatterToXML::m_encodingIsUTF`[protected]`

| Flag to quickly tell if the encoding is capable of full Unicode support.

bool FormatterToXML::m_inCData`[protected]`

| Tells if we're in CData section.

int FormatterToXML::m_indent`[protected]`

| Amount to indent.

bool FormatterToXML::m_ispreserve`[protected]`

| State flag to tell if preservation of whitespace is important.

bool FormatterToXML::m_isprevtext`[protected]`

| State flag that tells if the previous node processed was text, so we can tell if we should preserve whitespace.

XalanDOMChar FormatterToXML::m_maxCharacter`[protected]`

| The maximum character size before we have to resort to escaping.

bool FormatterToXML::m_needToOutputDocTypeDecl`[protected]`

| Flag to tell that we need to add the doctype decl, which we can't do until the first element is encountered.

bool FormatterToXML::m_nextIsRaw`[protected]`

| Tell if the next text should be raw.

BoolStackType FormatterToXML::m_preserves`[protected]`

| Stack to keep track of whether or not we need to preserve whitespace.

bool FormatterToXML::m_shouldWriteXMLHeader`[protected]`

| If true, XML header should be written to output.

bool FormatterToXML::m_startNewLine`[protected]`

| Flag to signal that a newline should be added.

XalanOutputStream *const FormatterToXML::m_stream`[protected]`

| The stream where the XML will be written.

XalanDOMString FormatterToXML::m_stringBuffer`[protected]`

bool FormatterToXML::m_stripCData`[protected]`

| If true, cdata sections are simply stripped of their CDATA brackets, without escaping.

Writer *const FormatterToXML::m_writer`[protected]`

| The writer where the XML will be written.

The documentation for this class was generated from the following file:

- FormatterToXML.hpp

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.10 Copyright © 1999-2004 The Apache Software Foundation. All Rights Reserved.