DOM load and save flow
load on the DAE object just checks whether an I/O plug-in and DOM database exist, creating default ones if they don’t (creates and instantiates an object of the default
Database class), then calls
read in the I/O plug-in.
libxml I/O plug-in contains the following functions used while reading:
readcalls a recursive function that reads the XML element hierarchy using
libxml’s SAX parsing functionality.
nextElementcalls the appropriate functions based on the XML SAX type currently being parsed, that is, an attribute, a value, or a new element.
readAttributeshandles the white space delimiting of array values. It then calls the current element's
setAttributefunction. (See DOM meta system for information on what this does.) This has a nasty, but purposely designed, side effect that if the element is an array type, the particle is appended to the attribute type list and is not actually “set”.
readValuedoes the same as
readAttributesexcept it doesn’t call
setAttributeon the element but instead uses the meta value attribute (more in DOM meta system) to set the data.
libxml plug-in reads and converts all of the XML document, it does the following:
- Creates a daeDocument with the root being the root that was created on parse.
- Creates all of the integration objects if they are used.
- Resolves all elements that require resolution (more in DOM meta system).
- Calls the integration object conversion functions.
save just checks whether the I/O plug-in and DOM database exist, creating them if they don’t. (If there is no database, then
save will most certainly fail, but it creates it anyway.) Then it calls
write in the I/O plug-in.
libxml I/O plug-in does the following while writing:
libxml2’s SAX writer to write the COLLADA document.
- Calls a recursive
writeElement, that writes each element and its child subtree.
- Does some special-case handling if you have the option set to save the float data as a .raw file. ((more on this later))
- If an element’s meta type is not flagged transparent then a new XML tag is created and the attributes are written by calling
writeAttribute. (See DOM code generator for rules on what is marked transparent.)
writeAttributedoes some processing to check whether an attribute should be written:
- Does some special case handling so string types aren’t bound by the same size constraints that other types are.
- Attributes that are required are always written. An element’s value is an attribute that is always considered required.
- If the attribute is not required, it checks whether it was set. If not, then it is not written.
- If the attribute is set then it is compared to the default value, if one was specified. If the attribute is the same as the default then it ignored. This always fails for array types (I think).
|COLLADA DOM - Version 2.4 Historical Reference|
|List of main articles under the DOM portal.|
| User Guide chapters: • Intro • Architecture • Setting up • Working with documents • Creating docs • Importing docs • Representing elements • Working with elements • Resolving URIs • Resolving SIDs • Using custom COLLADA data • Integration templates • Error handling|
Systems: • URI resolver • Meta • Load/save flow • Runtime database • Memory • StringRef • Code generator