# XmlContainer.putDocument

`

###

    import com.sleepycat.dbxml.*;

    public int putDocument(DbTxn txnid, XmlDocument xmldoc, int flags)
        throws DbException;

# Description

The XmlContainer.putDocument method stores a XML document into the container and returns the document ID. The contents of an XmlDocument may be of type Db.XmlDocument::BYTES or Db.XmlDocument::XML. XML content is parsed and indexed as per the container indexing specification. Non-XML (Db.XmlDocument::BYTES) content is not indexed.

Regardless of the content type the document annotation attributes are always indexed.]

The XML indexer expects XML content to be encoded as UTF-8. The indexer also expects the XML content to be well-formed, but the content need not be valid.

If the operation is to be transaction-protected (other than by specifying the Db.DB_AUTO_COMMIT flag), the txnid parameter is a transaction handle returned from DbEnv.txn_begin; otherwise, null.

The flags value must be set to 0 or the following value:

Db.DB_AUTO_COMMIT
  Enclose the XmlContainer.putDocument call within a transaction. If the call succeeds, changes made by the operation will be recoverable. If the call fails, the operation will have made no changes.

The XmlContainer.putDocument method returns a document ID on success. Otherwise, the XmlContainer.putDocument method throws an exception that encapsulates a non-zero error value on failure.

# Errors

If the operation was selected to resolve a deadlock, the XmlContainer.putDocument method will fail and throw a DbDeadlockException exception.

The XmlContainer.putDocument method may fail and throw an exception for errors specified for other Berkeley DB and C library or system methods. If a catastrophic error has occurred, the XmlContainer.putDocument method may fail and throw a DbRunRecoveryException, in which case all subsequent Berkeley DB calls will fail in the same way.

# Class

XmlContainer, XmlDocument, XmlQueryContext

# See Also

XmlContainer.close, XmlContainer.declareIndex, XmlContainer.deleteDocument, XmlContainer.getDocument, XmlContainer.getName, XmlContainer.open, XmlContainer.putDocument and XmlContainer.queryWithXPath.

XmlDocument.getAttributeValue, XmlDocument.getContent, XmlDocument.getID, XmlDocument.getName, XmlDocument.getType, XmlDocument.setContent, XmlDocument.setName, and XmlDocument.setType.

`

Copyright Sleepycat Software