}
void
-cxml::Node::write (xmlpp::Node* parent) const
+cxml::Node::write (xmlpp::Node* parent, map<cxml::ConstNodePtr, xmlpp::Node*>* mapping) const
{
xmlpp::Element* node = parent->add_child (_name, _namespace_prefix);
+ if (mapping) {
+ (*mapping)[shared_from_this()] = node;
+ }
if (!_content.empty ()) {
node->add_child_text (_content);
return node;
}
-static void
-write_to_xmlpp_document (cxml::ConstNodePtr node, xmlpp::Document& doc)
+void
+cxml::write_to_xmlpp_document (cxml::ConstNodePtr node, xmlpp::Document& doc, map<cxml::ConstNodePtr, xmlpp::Node*>* mapping)
{
xmlpp::Element* root = doc.create_root_node (node->name ());
+ if (mapping) {
+ (*mapping)[node] = root;
+ }
cxml::KeyValueList namespace_declarations = node->namespace_declarations ();
for (cxml::KeyValueList::const_iterator i = namespace_declarations.begin(); i != namespace_declarations.end(); ++i) {
cxml::NodeList children = node->children ();
for (cxml::NodeList::const_iterator i = children.begin(); i != children.end(); ++i) {
- (*i)->write (root);
+ (*i)->write (root, mapping);
}
}