summaryrefslogtreecommitdiffstats
path: root/sca-cpp/trunk/kernel/xml.hpp
diff options
context:
space:
mode:
authorjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2010-01-24 09:27:52 +0000
committerjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2010-01-24 09:27:52 +0000
commit878131a50cf9651fc8de402420b8c94696328a3c (patch)
treed0112887a0204bbf6ad9e76ae062ca4b70bc094a /sca-cpp/trunk/kernel/xml.hpp
parent1c21d758af81d880ad6e045d18f8bc62ad8be89e (diff)
Working Web service component using Axis2C 1.6. Some fixes to the JSON conversion functions to correctly handle all cases of nested objects and arrays. Added support for component properties, the Web service component has a URI property that can be configured to the address of the target Web service.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@902540 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-cpp/trunk/kernel/xml.hpp')
-rw-r--r--sca-cpp/trunk/kernel/xml.hpp30
1 files changed, 21 insertions, 9 deletions
diff --git a/sca-cpp/trunk/kernel/xml.hpp b/sca-cpp/trunk/kernel/xml.hpp
index 9e903ea34d..fa1701d83a 100644
--- a/sca-cpp/trunk/kernel/xml.hpp
+++ b/sca-cpp/trunk/kernel/xml.hpp
@@ -290,16 +290,20 @@ const failable<bool> writeList(const list<value>& l, const xmlTextWriterPtr xml)
/**
* Write a list of values to a libxml2 XML writer.
*/
-const failable<bool> write(const list<value>& l, const xmlTextWriterPtr xml) {
- if (xmlTextWriterStartDocument(xml, NULL, encoding, NULL) < 0)
- return mkfailure<bool>(string("xmlTextWriterStartDocument failed"));
+const failable<bool> write(const list<value>& l, const xmlTextWriterPtr xml, bool xmlTag) {
+ if (xmlTag) {
+ if (xmlTextWriterStartDocument(xml, NULL, encoding, NULL) < 0)
+ return mkfailure<bool>(string("xmlTextWriterStartDocument failed"));
+ }
const failable<bool> w = writeList(l, xml);
if (!hasContent(w))
return w;
- if (xmlTextWriterEndDocument(xml) < 0)
- return mkfailure<bool>("xmlTextWriterEndDocument failed");
+ if (xmlTag) {
+ if (xmlTextWriterEndDocument(xml) < 0)
+ return mkfailure<bool>("xmlTextWriterEndDocument failed");
+ }
return true;
}
@@ -326,7 +330,7 @@ template<typename R> int writeCallback(void *context, const char* buffer, int le
/**
* Convert a list of values to an XML document.
*/
-template<typename R> const failable<R> writeXML(const lambda<R(const string&, const R)>& reduce, const R& initial, const list<value>& l) {
+template<typename R> const failable<R> writeXML(const lambda<R(const string&, const R)>& reduce, const R& initial, const list<value>& l, const bool xmlTag) {
XMLWriteContext<R> cx(reduce, initial);
xmlOutputBufferPtr out = xmlOutputBufferCreateIO(writeCallback<R>, NULL, &cx, NULL);
if (out == NULL)
@@ -335,7 +339,7 @@ template<typename R> const failable<R> writeXML(const lambda<R(const string&, co
if (xml == NULL)
return mkfailure<R>("xmlNewTextWriter failed");
- const failable<bool> w = write(l, xml);
+ const failable<bool> w = write(l, xml, xmlTag);
xmlFreeTextWriter(xml);
if (!hasContent(w)) {
return mkfailure<R>(reason(w));
@@ -343,15 +347,23 @@ template<typename R> const failable<R> writeXML(const lambda<R(const string&, co
return cx.accum;
}
+template<typename R> const failable<R> writeXML(const lambda<R(const string&, const R)>& reduce, const R& initial, const list<value>& l) {
+ return writeXML(reduce, initial, l, true);
+}
+
/**
* Convert a list of values to a list of strings representing an XML document.
*/
-const failable<list<string> > writeXML(const list<value>& l) {
- const failable<list<string> > ls = writeXML<list<string> >(rcons<string>, list<string>(), l);
+const failable<list<string> > writeXML(const list<value>& l, const bool xmlTag) {
+ const failable<list<string> > ls = writeXML<list<string> >(rcons<string>, list<string>(), l, xmlTag);
if (!hasContent(ls))
return ls;
return reverse(list<string>(content(ls)));
}
+const failable<list<string> > writeXML(const list<value>& l) {
+ return writeXML(l, true);
+}
+
}
#endif /* tuscany_xml_hpp */