Talk:DOM guide: Working with documents/old version

From COLLADA Public Wiki
< Talk:DOM guide: Working with documents
Revision as of 00:48, 31 May 2007 by Elf (talk | contribs) (rm catg from talk pg)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

NOTE: This is an obsolete version of this article. It is preserved here primarily to preserve its edit history; all the content from here was moved to other articles and now we're going to reuse the article title for something else.


After you have loaded a COLLADA instance document, or before saving one, it is represented in the DOM runtime database. You can manipulate the DOM representation of documents in the database using the daeDatabase object.

Querying Documents

Three functions allow you to query for and iterate over documents in the runtime database:

  • daeDatabase::getDocumentCount
  • daeDatabase::getDocument
  • daeDatabase::isDocumentLoaded

The following function removes a document from the runtime database. Removing a document removes the root element and subsequently the entire element heirarchy from the database:

  • daeDatabase::removeDocument

Creating New Documents

You can use the COLLADA DOM to create a set of elements, add them to an empty database, and write the database to a COLLADA instance document. To do this, you need to ensure that you have a database created for use. When calling DAE::load or DAE::saveAs, the COLLADA DOM creates the default database and backend to use for those operations. If you start by creating data from scratch then you must ensure that there is a backend and a database created for use. To create and use the default database and backend, call

collada_dom->setDatabase(NULL);
collada_DOM->setIOPlugin(NULL);

Each document in the COLLADA DOM requres a domCOLLADA element as the root element for the document. These functions create a domCOLLADA root element automatically:

  • daeDatabase::insertDocument(daeString, daeDocument**)
  • daeDatabase::createDocument(daeString, daeDocument**)

These functions allow you to pass in an existing domCOLLADA element to be used for the document root:

  • daeDatabase::insertDocument(daeString, daeElement*, daeDocument**)
  • daeDatabase::createDocument(daeString, daeElement*, daeDocument**)

These functions create a daeDocument and insert it into the database. The document created is returned in the last argument:

  • daeDatabase::insertDocument(daeString, daeDocument**)
  • daeDatabase::insertDocument(daeString, daeElement*, daeDocument**)

The daeDatabase::createDocument functions allow you to create a new COLLADA document without inserting it into the database. You can later call daeDatabase::insertDocument( daeDocument *c ) to insert the document into the database.

Template:DOM tutorial