summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NEWS4
-rw-r--r--documentation/cxx/tree/manual/index.xhtml37
-rw-r--r--examples/cxx/tree/mixed/driver.cxx8
-rw-r--r--libxsd/xsd/cxx/tree/elements.hxx4
4 files changed, 44 insertions, 9 deletions
diff --git a/NEWS b/NEWS
index aa34222..16c87cf 100644
--- a/NEWS
+++ b/NEWS
@@ -17,6 +17,10 @@ C++/Tree
strings. This can be useful if your documents contain a large number
of repetitive strings.
+ * To get the DOM association in the copy of an object model tree one
+ now needs to explicitly pass the keep_dom flag as the second argument
+ to the copy constructor or clone() function.
+
Version 3.3.0
* New option, --char-encoding, allows you to specify the character encoding
diff --git a/documentation/cxx/tree/manual/index.xhtml b/documentation/cxx/tree/manual/index.xhtml
index 191cf70..8df33e3 100644
--- a/documentation/cxx/tree/manual/index.xhtml
+++ b/documentation/cxx/tree/manual/index.xhtml
@@ -5788,10 +5788,39 @@ XMLPlatformUtils::Terminate ();
call, you need to initialize the Xerces-C++ runtime before calling
one of the parsing functions with the <code>keep_dom</code> flag and
terminate it after the object model is destroyed (see
- <a href="#3.1">Section 3.1, "Initializing the Xerces-C++ Runtime"</a>).
- The DOM association is also maintained in complete copies of the
- object model (that is, the DOM document is cloned and associations
- are reestablished).</p>
+ <a href="#3.1">Section 3.1, "Initializing the Xerces-C++ Runtime"</a>).</p>
+
+ <p>If the <code>keep_dom</code> flag is passed
+ as the second argument to the copy constructor and the copy
+ being made is of a complete tree, then the DOM association
+ is also maintained in the copy by cloning the underlying
+ DOM document and reestablishing the associations. For example:</p>
+
+ <pre class="c++">
+using namespace xercesc;
+
+XMLPlatformUtils::Initialize ();
+
+{
+ // Parse XML to object model.
+ //
+ std::auto_ptr&lt;type> r = root (
+ "root.xml",
+ xml_schema::flags::keep_dom |
+ xml_schema::flags::dont_initialize);
+
+ // Copy without DOM association.
+ //
+ type copy1 (*r);
+
+ // Copy with DOM association.
+ //
+ type copy2 (*r, xml_schema::flags::keep_dom);
+}
+
+XMLPlatformUtils::Terminate ();
+ </pre>
+
<p>To obtain the corresponding DOM node from an object model node
you will need to call the <code>_node</code> accessor function
diff --git a/examples/cxx/tree/mixed/driver.cxx b/examples/cxx/tree/mixed/driver.cxx
index d905421..3347d7f 100644
--- a/examples/cxx/tree/mixed/driver.cxx
+++ b/examples/cxx/tree/mixed/driver.cxx
@@ -47,10 +47,12 @@ main (int argc, char* argv[])
xml_schema::flags::keep_dom |
xml_schema::flags::dont_initialize));
- // Note that DOM association is preserved in copies but only if they
- // are "complete", i.e., made from the root of the tree.
+ // The DOM association can be recreated in a copy (the underlying
+ // DOM document is cloned) if explicitly requested with the keep_dom
+ // flag and only if this copy is "complete", i.e., made from the root
+ // of the tree.
//
- text copy (*t);
+ text copy (*t, xml_schema::flags::keep_dom);
// Print text.
//
diff --git a/libxsd/xsd/cxx/tree/elements.hxx b/libxsd/xsd/cxx/tree/elements.hxx
index 8705c20..53420aa 100644
--- a/libxsd/xsd/cxx/tree/elements.hxx
+++ b/libxsd/xsd/cxx/tree/elements.hxx
@@ -968,10 +968,10 @@ namespace xsd
};
inline _type::
- _type (const type& x, flags, container* c)
+ _type (const type& x, flags f, container* c)
: container_ (c)
{
- if (x.dom_info_.get ())
+ if (x.dom_info_.get () != 0 && (f & flags::keep_dom))
{
std::auto_ptr<dom_info> r (x.dom_info_->clone (*this, c));
dom_info_ = r;