aboutsummaryrefslogtreecommitdiff
path: root/libxsd/xsd/cxx/tree/serialization.txx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2014-07-03 09:57:09 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2014-07-03 09:57:09 +0200
commit1a4099b78717b16f632b0e7e0980a27811221e52 (patch)
tree87a63393fc207082b7418987309581a9a79e49a4 /libxsd/xsd/cxx/tree/serialization.txx
parent06258b8eae3d5af9a1af0206bb5a8e5c80dde455 (diff)
Implement anyType and anySimpleType content representation
anyType as a DOM fragment, similar to wildcards. anySimpleType as a text string.
Diffstat (limited to 'libxsd/xsd/cxx/tree/serialization.txx')
-rw-r--r--libxsd/xsd/cxx/tree/serialization.txx41
1 files changed, 34 insertions, 7 deletions
diff --git a/libxsd/xsd/cxx/tree/serialization.txx b/libxsd/xsd/cxx/tree/serialization.txx
index e6fea1f..055f603 100644
--- a/libxsd/xsd/cxx/tree/serialization.txx
+++ b/libxsd/xsd/cxx/tree/serialization.txx
@@ -91,9 +91,29 @@ namespace xsd
// Insertion operators for type.
//
inline void
- operator<< (xercesc::DOMElement& e, const type&)
+ operator<< (xercesc::DOMElement& e, const type& x)
{
xml::dom::clear<char> (e);
+
+ if (!x.null_content () && x.dom_content ().present ())
+ {
+ // Clone the contents of the element.
+ //
+ using namespace xercesc;
+
+ DOMDocument& doc (*e.getOwnerDocument ());
+ const DOMElement& se (x.dom_content ().get ());
+ DOMNamedNodeMap& sa (*se.getAttributes ());
+
+ for (XMLSize_t i (0), n (sa.getLength ()); i != n; ++i)
+ e.setAttributeNode (
+ static_cast<DOMAttr*> (doc.importNode (sa.item (i), true)));
+
+ for (DOMNode* sn (se.getFirstChild ());
+ sn != 0;
+ sn = sn->getNextSibling ())
+ e.appendChild (doc.importNode (sn, true));
+ }
}
inline void
@@ -109,23 +129,30 @@ namespace xsd
// Insertion operators for simple_type.
//
- template <typename B>
+ template <typename C, typename B>
inline void
- operator<< (xercesc::DOMElement& e, const simple_type<B>&)
+ operator<< (xercesc::DOMElement& e, const simple_type<C, B>& x)
{
- xml::dom::clear<char> (e);
+ if (x.null_content ())
+ xml::dom::clear<char> (e);
+ else
+ e << x.text_content ();
}
- template <typename B>
+ template <typename C, typename B>
inline void
- operator<< (xercesc::DOMAttr&, const simple_type<B>&)
+ operator<< (xercesc::DOMAttr& a, const simple_type<C, B>& x)
{
+ if (!x.null_content ())
+ a << x.text_content ();
}
template <typename C, typename B>
inline void
- operator<< (list_stream<C>&, const simple_type<B>&)
+ operator<< (list_stream<C>& ls, const simple_type<C, B>& x)
{
+ if (!x.null_content ())
+ ls << x.text_content ();
}
// Insertion operators for list.