Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNo next file
LEIF Core Library Reference Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

LEIF::XmlWriter

Group:  XML Related

HIERARCHY

Local Index

Members

Header File

#include <rw/leif/core/XmlWriter.h>

Description

Class LEIF::XmlWriter is an abstract base class that provides an interface for writing XML messages. A derived class implements the protected methods to write output to a specific data sink, such as a LEIF::CString, a file, or a socket. Applications typically do not use classes derived from LEIF::XmlWriter directly. Instead, the application passes the writer to the marshal() method of a class generated by LEIF.

This class implements methods for creating and formatting XML elements. LEIF::XmlWriter also manages namespace declarations. The class uses the concept of a namespace scope for determining when to add a namespace declaration. A namespace scope extends from the point at which an element start tag is declared with writeElementStart() until an element end tag is declared with writeElementEnd(). Namespace scopes nest. When creating an element tag, the writer includes namespace declarations for namespaces that are not in scope.

Note that a LEIF::XmlWriter does not automatically produce a namespace declaration for the xsi:type attribute. An application must take care to declare the xsi namespace before producing an element with a schema type attribute. Classes generated by LEIF handle this transparently, so this is only a consideration if an application produces XML output outside of a marshal() method provided in a generate classes.

This class is intended to be flexible and suitable for use with streamed output. Therefore, the class does not strictly enforce well-formed XML. For example, there is no requirement that the name passed to writeElementEnd() match the name passed to the most recent call to writeElementStart().

Public Typedefs

typedef enum { Start, InProgress } WriteState;

Static Constants

static const LEIF::CString XmlNamespaceTag;
static const LEIF::CString Blank;
static const LEIF::CString Colon;
static const LEIF::CString Newline;
static const LEIF::CString EqualToAndQuotes;
static const LEIF::CString Quotes;
static const LEIF::CString TrueValue;
static const LEIF::CString FalseValue;
static const LEIF::CString StartTag;
static const LEIF::CString EndTag;
static const LEIF::CString StartEndTag;
static const LEIF::CString UnpairedTag;
static const LEIF::CString MarkupGt;
static const LEIF::CString MarkupLt;
static const LEIF::CString MarkupAmpersand;
static const LEIF::CString MarkupQuotes;
static const LEIF::CString MarkupApos;
static const LEIF::CString        MarkupCR;

Public Constructor

XmlWriter();

Public Destructor:

virtual ~XmlWriter();

Public Member Functions:

void
addNamespace(const LEIF::XmlNamespace& ns);
void
decrementIndent();
int
getCurrentIndent() const;
bool
getIgnoreWhitespace() const;
bool                                    getMustEscapeTextDefault() const;
int
getSizeOfIndent() const;
void
incrementIndent();
void
setCurrentIndent(int indent);
void
setIgnoreWhitespace(bool ignore);
void                                    setMustEscapeTextDefault( bool escape );
int
setSizeOfIndent(int indentSize);
void
write(const LEIF::CString& text);
void
write(const LEIF::CString& text,
      bool mustEscapeText);
void
writeAttribute(const LEIF::CString& name,
    const LEIF::CString& value, bool mustEscapeText = true);
void
writeAttribute(const LEIF::XmlName& name,
    const LEIF::CString& value, bool mustEscapeText = true);
void
writeElementStart(const LEIF::XmlName& name,
    const LEIF::XmlAttributeSet& attributes =
    LEIF::XmlAttributeSet(), bool emptyElement = false);
void
writeElementEnd(const LEIF::XmlName& name);
void
writeIndentChars();
void
writeNewLine();
void
writeSimpleElement(const LEIF::CString& name,
    const LEIF::CString& value,
    const LEIF::CString& schemaType,
    bool includeTypeAttribute = false);
void
writeSimpleElement(const LEIF::XmlName& name,
    const LEIF::CString& value,
    const LEIF::CString& schemaType,
    bool includeTypeAttribute = false);

Protected Member Functions

virtual void
writeToSink(const LEIF::CString& text) = 0;
virtual void                            
writeToSink(const char* str, size_t len);
virtual void
writeToSink(char c) = 0;
virtual void
flush() = 0;

See Also

LEIF::XmlStringWriter



Previous fileTop of DocumentContentsIndex pageNo next file

©2003-2005 Copyright Quovadx, Inc. All Rights Reserved.
Rogue Wave is a registered trademark of Quovadx, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.