95{
96
97 int record_packing = Z_SRW_recordPacking_XML;
98 if (er_req && er_req->recordPacking && 's' == *(er_req->recordPacking))
99 record_packing = Z_SRW_recordPacking_string;
100
101
102 Z_SRW_explainResponse *sru_res = sru_pdu_res->u.explain_response;
103
104
105 sru_res->record.recordPosition = odr_intdup(odr_en, 1);
106 sru_res->record.recordPacking = record_packing;
107 sru_res->record.recordSchema = odr_strdup(odr_en,
xmlns_explain.c_str());
108
109 if (explain == 0 || explain->doc == 0)
110 {
111 std::string explain_xml
112 = mp_util::to_string(
114 " <serverInfo protocol='SRU'>\n"
115 " <host>")
117 + mp_util::to_string("</host>\n"
118 " <port>")
120 + mp_util::to_string("</port>\n"
121 " <database>")
123 + mp_util::to_string("</database>\n"
124 " </serverInfo>\n"
125 "</explain>\n");
126
127 sru_res->record.recordData_len = explain_xml.size();
128 sru_res->record.recordData_buf = odr_strdup(odr_en, explain_xml.c_str());
129 }
130 else
131 {
132 xmlNode *tmp = xmlCopyNode((xmlNode *) explain, 1);
133 xmlBufferPtr buf = xmlBufferCreate();
134 xmlNodeDump(buf, tmp->doc, tmp, 2, 1);
135 xmlFreeNode(tmp);
136 sru_res->record.recordData_len = buf->use;
137 sru_res->record.recordData_buf = odr_strdupn(odr_en, (const char *) buf->content, buf->use);
138 xmlBufferFree(buf);
139 }
140}
const std::string xmlns_explain("http://explain.z3950.org/dtd/2.0/")