Question

I'm working on a project to add COLLADA export functionality to an existing program (PyMOL), and trying to use the COLLADA DOM library to help write the output file. There is an existing structure for the various "save" functions that I would like to follow, wherein the text to be exported is appended to a variable-length array, which is then written to disk by the parent function.

The trouble I'm having is this: I haven't found a way to output the COLLADA file as a string so I can append it to the VLA. All the DOM examples I've found work directly with files, reading from and saving to them, and after spending several days combing through the source, I can't find a function that will return the XML string for a DAE (COLLADA) object.

For example, it's possible to write a file to disk using the DOM's write() or writeAll() functions, like this example from the DOM Guide:

#include <dae.h>

int main() {
    DAE dae;
    dae.add("simple.dae");
    dae.writeAll();
    return 0;
}

What I'd like to do instead is something like this:

string generateXmlString() {
    DAE dae;
    dae.add("simple.dae");
    string output = dae.getXml("simple.dae");  // this function doesn't exist
    return output;
}

where the XML string is generated and instead either assigned to a variable or returned directly, instead of being written to a file.

Is there a way to do this using COLLADA DOM? If so, I would love to see an example.

Alternatively, is there another library that would allow me to accomplish this in a more straightforward manner?

Thanks!

Was it helpful?

Solution

I tried to get COLLADA DOM working for quite a while, but eventually gave up and decided to use libxml2 instead. It's well documented and just as easy to use, and doesn't add much in the way of extra dependencies, as it's preinstalled on many UNIX-like systems.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top