- std::string explain_xml
- = mp_util::to_string(
- "<explain>\n"
- " <serverInfo protocol='SRU'>\n"
- " <host>")
- + host
- + mp_util::to_string("</host>\n"
- " <port>")
- + port
- + mp_util::to_string("</port>\n"
- " <database>")
- + database
- + mp_util::to_string("</database>\n"
- " </serverInfo>\n"
- "</explain>\n");
-
+ std::string explain_xml;
+
+ if (explain == 0){
+ explain_xml
+ = mp_util::to_string(
+ "<explain xmlns=\"" + xmlns_explain + "\">\n"
+ " <serverInfo protocol='SRU'>\n"
+ " <host>")
+ + sruinfo.host
+ + mp_util::to_string("</host>\n"
+ " <port>")
+ + sruinfo.port
+ + mp_util::to_string("</port>\n"
+ " <database>")
+ + sruinfo.database
+ + mp_util::to_string("</database>\n"
+ " </serverInfo>\n"
+ "</explain>\n");
+ }
+ else {
+ // make new XML DOC with given explain node
+ xmlDocPtr doc = xmlNewDoc(BAD_CAST "1.0");
+ xmlDocSetRootElement(doc, (xmlNode*)explain);
+
+ xmlChar *xmlbuff;
+ int xmlbuffsz;
+ xmlDocDumpFormatMemory(doc, &xmlbuff, &xmlbuffsz, 1);
+
+ explain_xml.assign((const char*)xmlbuff, 0, xmlbuffsz);
+ }
+
+
+ // z3950'fy recordPacking
+ int record_packing = Z_SRW_recordPacking_XML;
+ if (er_req && er_req->recordPacking && 's' == *(er_req->recordPacking))
+ record_packing = Z_SRW_recordPacking_string;