Multi-line svn commit, see body.
[shibboleth/cpp-xmltooling.git] / xmltooling / io / AbstractXMLObjectMarshaller.cpp
index e6a10f4..a33016c 100644 (file)
@@ -181,8 +181,7 @@ void AbstractXMLObjectMarshaller::marshallInto(
     marshallElementType(targetElement);\r
     marshallNamespaces(targetElement);\r
     marshallAttributes(targetElement);\r
-    marshallChildElements(targetElement);\r
-    marshallElementContent(targetElement);\r
+    marshallContent(targetElement);\r
     \r
 #ifndef XMLTOOLING_NO_XMLSEC\r
     if (sigs) {\r
@@ -290,17 +289,21 @@ void AbstractXMLObjectMarshaller::marshallNamespaces(DOMElement* domElement) con
     for_each(namespaces.begin(),namespaces.end(),bind1st(_addns(),domElement));\r
 }\r
 \r
-class _marshallit : public binary_function<const XMLObject*,DOMElement*,void> {\r
-public:\r
-    void operator()(const XMLObject* xo, DOMElement* e) const {\r
-        if (xo) xo->marshall(e);\r
-    }\r
-};\r
-\r
-void AbstractXMLObjectMarshaller::marshallChildElements(DOMElement* domElement) const\r
+void AbstractXMLObjectMarshaller::marshallContent(DOMElement* domElement) const\r
 {\r
-    XT_log.debug("marshalling child elements for XMLObject");\r
-\r
+    XT_log.debug("marshalling text and child elements for XMLObject");\r
+    \r
+    const XMLCh* val;\r
+    unsigned int pos=0;\r
     const list<XMLObject*>& children=getOrderedChildren();\r
-    for_each(children.begin(),children.end(),bind2nd(_marshallit(),domElement));\r
+    for (list<XMLObject*>::const_iterator i=children.begin(); i!=children.end(); ++i, ++pos) {\r
+        val = getTextContent(pos);\r
+        if (val && *val)\r
+            domElement->appendChild(domElement->getOwnerDocument()->createTextNode(val));\r
+        if (*i)\r
+            (*i)->marshall(domElement);\r
+    }\r
+    val = getTextContent(pos);\r
+    if (val && *val)\r
+        domElement->appendChild(domElement->getOwnerDocument()->createTextNode(val));\r
 }\r