Logo Search packages:      
Sourcecode: poco version File versions  Download package

Poco::XML::XMLWriter Class Reference

#include <XMLWriter.h>

Inheritance diagram for Poco::XML::XMLWriter:

Poco::XML::ContentHandler Poco::XML::LexicalHandler Poco::XML::DTDHandler

List of all members.


Detailed Description

This class serializes SAX2 ContentHandler, LexicalHandler and DTDHandler events back into a stream.

Various consistency checks are performed on the written data (i.e. there must be exactly one root element and every startElement() must have a matching endElement()).

The XMLWriter supports optional pretty-printing of the serialized XML. Note, however, that pretty-printing XML data alters the information set of the document being written, since in XML all whitespace is potentially relevant to an application.

The writer contains extensive support for XML Namespaces, so that a client application does not have to keep track of prefixes and supply xmlns attributes.

If the client does not provide namespace prefixes (either by specifying them as part of the qualified name given to startElement(), or by calling startPrefixMapping()), the XMLWriter automatically generates namespace prefixes in the form ns1, ns2, etc.

Definition at line 64 of file XMLWriter.h.


Public Types

enum  Options { CANONICAL = 0x00, WRITE_XML_DECLARATION = 0x01, PRETTY_PRINT = 0x02 }

Public Member Functions

void characters (const XMLString &str)
void characters (const XMLChar ch[], int start, int length)
 Writes an empty XML element tag with the given attributes (<elem attr1="value1"... />).
void comment (const XMLChar ch[], int start, int length)
 Writes the ]]> string that ends a CDATA section.
void dataElement (const XMLString &namespaceURI, const XMLString &localName, const XMLString &qname, const XMLString &data, const XMLString &attr1=XMLString(), const XMLString &value1=XMLString(), const XMLString &attr2=XMLString(), const XMLString &value2=XMLString(), const XMLString &attr3=XMLString(), const XMLString &value3=XMLString())
 Does nothing.
void emptyElement (const XMLString &namespaceURI, const XMLString &localName, const XMLString &qname, const Attributes &attributes)
 Writes an empty XML element tag (<elem>).
void emptyElement (const XMLString &namespaceURI, const XMLString &localName, const XMLString &qname)
void endCDATA ()
void endDocument ()
void endDTD ()
 Writes a DTD declaration.
void endElement (const XMLString &namespaceURI, const XMLString &localName, const XMLString &qname)
void endEntity (const XMLString &name)
 Does nothing.
void endFragment ()
void endPrefixMapping (const XMLString &prefix)
const std::string & getNewLine () const
void ignorableWhitespace (const XMLChar ch[], int start, int length)
void notationDecl (const XMLString &name, const XMLString *publicId, const XMLString *systemId)
 Does nothing.
void processingInstruction (const XMLString &target, const XMLString &data)
void rawCharacters (const XMLString &str)
void setDocumentLocator (const Locator *loc)
 Returns the line ending currently in use.
void setNewLine (const std::string &newLineCharacters)
 Destroys the XMLWriter.
void skippedEntity (const XMLString &name)
 End the scope of a prefix-URI mapping.
void startCDATA ()
 Writes a data element in the form <name attr1="value1"...>data</name>.
void startDocument ()
 Currently unused.
void startDTD (const XMLString &name, const XMLString &publicId, const XMLString &systemId)
 Writes a comment.
void startElement (const XMLString &namespaceURI, const XMLString &localName, const XMLString &qname)
void startElement (const XMLString &namespaceURI, const XMLString &localName, const XMLString &qname, const Attributes &attributes)
 Checks that all elements are closed and prints a final newline.
void startEntity (const XMLString &name)
 Writes the closing characters of a DTD declaration.
void startFragment ()
 Checks that all elements are closed and prints a final newline.
void startPrefixMapping (const XMLString &prefix, const XMLString &namespaceURI)
 Writes a processing instruction.
void unparsedEntityDecl (const XMLString &name, const XMLString *publicId, const XMLString &systemId, const XMLString &notationName)
 XMLWriter (XMLByteOutputStream &str, int options, const std::string &encodingName, Poco::TextEncoding *pTextEncoding)
 XMLWriter (XMLByteOutputStream &str, int options, const std::string &encodingName, Poco::TextEncoding &textEncoding)
 XMLWriter (XMLByteOutputStream &str, int options)
 ~XMLWriter ()

Static Public Attributes

static const std::string NEWLINE_CR = "\r"
static const std::string NEWLINE_CRLF = "\r\n"
static const std::string NEWLINE_DEFAULT
static const std::string NEWLINE_LF = "\n"

Protected Types

typedef std::map< XMLString,
XMLString > 
AttributeMap

Protected Member Functions

void addAttributes (AttributeMap &attributeMap, const Attributes &attributes, const XMLString &elementNamespaceURI)
void addNamespaceAttributes (AttributeMap &attributeMap)
void closeStartTag ()
void declareAttributeNamespaces (const Attributes &attributes)
XMLString newPrefix ()
void prettyPrint () const
void writeAttributes (const AttributeMap &attributeMap)
void writeEndElement (const XMLString &namespaceURI, const XMLString &localName, const XMLString &qname)
void writeIndent () const
void writeMarkup (const std::string &str) const
void writeName (const XMLString &prefix, const XMLString &localName)
void writeNewLine () const
void writeStartElement (const XMLString &namespaceURI, const XMLString &localName, const XMLString &qname, const Attributes &attributes)
void writeXML (XMLChar ch) const
void writeXML (const XMLString &str) const
void writeXMLDeclaration ()

Static Protected Member Functions

static std::string nameToString (const XMLString &localName, const XMLString &qname)

Private Types

typedef std::vector< NameElementStack

Private Attributes

bool _contentWritten
int _depth
int _elementCount
ElementStack _elementStack
std::string _encoding
bool _inCDATA
bool _inDTD
bool _inFragment
bool _inInternalDTD
NamespaceSupport _namespaces
std::string _newLine
int _options
Poco::TextEncoding_pInEncoding
Poco::TextEncoding_pOutEncoding
int _prefix
Poco::OutputStreamConverter_pTextConverter
bool _unclosedStartTag

Static Private Attributes

static const std::string MARKUP_AMPENC = "&amp;"
static const std::string MARKUP_APOSENC = "&apos;"
static const std::string MARKUP_BEGIN_CDATA = "<![CDATA["
static const std::string MARKUP_COLON = ":"
static const std::string MARKUP_END_CDATA = "]]>"
static const std::string MARKUP_EQQUOT = "=\""
static const std::string MARKUP_GT = ">"
static const std::string MARKUP_GTENC = "&gt;"
static const std::string MARKUP_LT = "<"
static const std::string MARKUP_LTENC = "&lt;"
static const std::string MARKUP_LTSLASH = "</"
static const std::string MARKUP_QUOT = "\""
static const std::string MARKUP_QUOTENC = "&quot;"
static const std::string MARKUP_SLASHGT = "/>"
static const std::string MARKUP_SPACE = " "
static const std::string MARKUP_TAB = "\t"

Classes

struct  Namespace

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

Generated by  Doxygen 1.6.0   Back to index