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

rwsf::XmlWriter

Group:  XML Related

HIERARCHY

Local Index

Members

Header File

#include <rwsf/core/XmlWriter.h>

Description

Class rwsf::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 an std::string, a file, or a socket. Applications typically do not use classes derived from rwsf::XmlWriter directly. Instead, the application passes the writer to the marshal() method of a class generated by Hydra.

This class implements methods for creating and formatting XML elements. rwsf::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 an rwsf::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 Hydra 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 std::string XmlNamespaceTag;
static const std::string Blank;
static const std::string Colon;
static const std::string Newline;
static const std::string EqualToAndQuotes;
static const std::string Quotes;
static const std::string TrueValue;
static const std::string FalseValue;
static const std::string StartTag;
static const std::string EndTag;
static const std::string StartEndTag;
static const std::string UnpairedTag;
static const std::string MarkupGt;
static const std::string MarkupLt;
static const std::string MarkupAmpersand;
static const std::string MarkupQuotes;
static const std::string MarkupApos;
static const std::string        MarkupCR;

Public Constructor

XmlWriter();

Public Destructor:

virtual ~XmlWriter();

Public Member Functions:

void
addNamespace(const rwsf::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 std::string& text);
void
write(const std::string& text,
      bool mustEscapeText);
void
writeAttribute(const std::string& name,
    const std::string& value, bool mustEscapeText = true);
void
writeAttribute(const rwsf::XmlName& name,
    const std::string& value, bool mustEscapeText = true);
void
writeElementStart(const rwsf::XmlName& name,
    const rwsf::XmlAttributeSet& attributes =
    rwsf::XmlAttributeSet(), bool emptyElement = false);
void
writeElementEnd(const rwsf::XmlName& name);
void
writeIndentChars();
void
writeNewLine();
void
writeSimpleElement(const std::string& name,
    const std::string& value,
    const std::string& schemaType,
    bool includeTypeAttribute = false);
void
writeSimpleElement(const rwsf::XmlName& name,
    const std::string& value,
    const std::string& schemaType,
    bool includeTypeAttribute = false);

Protected Member Functions

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

See Also

rwsf::XmlStringWriter



Previous fileTop of DocumentContentsIndex pageNo next file

©2004-2007 Copyright Quovadx, Inc. All Rights Reserved.
Quovadx and Rogue Wave are registered trademarks and HydraSDO is a 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.