質問

I am working with a library that uses XSD for creating objects from their XML-based format in C++.

Basically, the inheritance diagram looks something like this:

class BaseClass: public xsd::cxx::tree::type;
class MainXmlObject: public BaseClass;

I think I need to convert my MainXmlObject to a xerces::DOMDocument and then use DOMWriter to write the actual XML file, but I couldn't find the right routines so far.

What is the best way to do this?

役に立ちましたか?

解決

It seems like adding the --add-serialization flag to the xsd code generation and then using something like:

xml_schema::namespace_infomap map;
//    map[""].name = "test"; // xmlns
//    map[""].schema = "http://sbgn.org/libsbgn/0.2"; // xsi:noNamespaceSchemaLocation
ofstream ofs(fname.c_str());
sbgn_(ofs, s, map); // invoking the stream here
ofs.close();

works. References: Adding serialization and details from the XSD guide.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top