XmlContainer::putDocumentAsEventWriter

#include <DbXml.hpp>

XmlEventWriter &XmlContainer::putDocumentAsEventWriter(
    XmlDocument &document, XmlUpdateContext &context, 
    u_int32_t flags = 0)

XmlEventWriter &XmlContainer::putDocumentAsEventWriter(
    XmlTransaction &txn, XmlDocument &document, 
    XmlUpdateContext &context, u_int32_t flags = 0)

Begins insertion of an XmlDocument into the container through use of an XmlEventWriter object. Methods must be called on the returned XmlEventWriter to create content for the document, which is completed by calling XmlEventWriter::close. If XmlEventWriter::close is never called, the document insertion will not be complete, and the container may be left in an inconsistent state.

The name used for the document must be unique in the container or an exception is thrown. The flag, DBXML_GEN_NAME, can be used to generate a name. To change a document that already exists in the container, use XmlContainer::updateDocument.

Parameters

txn

If the operation is to be transaction-protected, the txn parameter is an XmlTransaction handle returned from XmlManager::createTransaction.

document

The XmlDocument to be inserted into the XmlContainer.

context

The update context to use for the document insertion.

flags

This parameter must be set to 0 or the following value:

  • DBXML_GEN_NAME

    Generate a unique name. If no name is set for this XmlDocument , a system-defined unique name is generated. If a name is specified, a unique string is appended to that name to ensure uniqueness.

Errors

The XmlContainer::putDocumentAsEventWriter method may fail and throw XmlException , encapsulating one of the following non-zero errors:

DATABASE_ERROR

An error occurred in an underlying Berkeley DB database. The XmlException::getDbErrno method will return the error code for the error.

UNIQUE_ERROR

Uniqueness constraint violation for key

Class

XmlContainer

See Also

XmlContainer Methods