return 0;
}
+static void encode_echoed_args(xmlNodePtr ptr, Z_SRW_PDU *p, const char *name)
+{
+ Z_SRW_extra_arg *ea = p->extra_args;
+ if (ea)
+ {
+ xmlNode *p1 = xmlNewChild(ptr, 0, BAD_CAST name, 0);
+ xmlNode *p2 = 0;
+ for (; ea; ea = ea->next)
+ {
+ if (ea->name && ea->name[0] == 'x' && ea->name[1] == '-')
+ {
+ /* not really according to XSD as of July 2014 */
+ if (!p2)
+ p2 = xmlNewChild(p1, 0,
+ BAD_CAST "extraRequestData", 0);
+ /* skip +2: "x-" in element */
+ add_xsd_string(p2, ea->name + 2, ea->value);
+ }
+ else
+ add_xsd_string(p1, ea->name, ea->value);
+ }
+ }
+}
+
int yaz_srw_codec(ODR o, void * vptr, Z_SRW_PDU **handler_data,
void *client_data, const char *ns)
{
}
add_xsd_integer(ptr, "nextRecordPosition",
res->nextRecordPosition);
- if ((*p)->extra_args)
- {
- xmlNode *p1 =
- xmlNewChild(ptr, 0, BAD_CAST "echoedSearchRetrieveRequest",
- 0);
- Z_SRW_extra_arg *ea = (*p)->extra_args;
- for (; ea; ea = ea->next)
- add_xsd_string(p1, ea->name, ea->value);
-
- }
+ encode_echoed_args(ptr, *p, "echoedSearchRetrieveRequest");
if (res->num_diagnostics)
{
xmlNodePtr rptr = xmlNewChild(ptr, 0, BAD_CAST "diagnostics",
yaz_srw_record(o, ptr1, &res->record, &res->extra_record,
client_data, version2);
}
- if ((*p)->extra_args)
- {
- xmlNode *p1 =
- xmlNewChild(ptr, 0, BAD_CAST "echoedExplainRequest", 0);
- Z_SRW_extra_arg *ea = (*p)->extra_args;
- for (; ea; ea = ea->next)
- add_xsd_string(p1, ea->name, ea->value);
- }
+ encode_echoed_args(ptr, *p, "echoedExplainRequest");
if (res->num_diagnostics)
{
xmlNodePtr rptr = xmlNewChild(ptr, 0, BAD_CAST "diagnostics",
return yaz_srw_get_pdu(o, which, "2.0");
}
+/* http://docs.oasis-open.org/search-ws/searchRetrieve/v1.0/os/schemas/sruResponse.xsd */
Z_SRW_PDU *yaz_srw_get_pdu_e(ODR o, int which, Z_SRW_PDU *req)
{
int version2 = !req->srw_version || strcmp(req->srw_version, "2.") > 0;
Z_SRW_PDU *res = yaz_srw_get_pdu(o, which, req->srw_version);
+ Z_SRW_extra_arg **l = &res->extra_args, *ea;
+ l = append_extra_arg(o, l, "version", req->srw_version);
if (req->which == Z_SRW_searchRetrieve_request &&
which == Z_SRW_searchRetrieve_response)
{
- Z_SRW_extra_arg **l = &res->extra_args;
- l = append_extra_arg(o, l, "version", req->srw_version);
if (req->u.request->queryType &&
strcmp(req->u.request->queryType, "cql"))
l = append_extra_arg(o, l, "queryType", req->u.request->queryType);
l = append_extra_arg(o, l, "sortKeys",
req->u.request->sort.sortKeys);
l = append_extra_arg(o, l, "stylesheet", req->u.request->stylesheet);
-
}
if (req->which == Z_SRW_explain_request &&
which == Z_SRW_explain_response)
{
- Z_SRW_extra_arg **l = &res->extra_args;
- l = append_extra_arg(o, l, "version", req->srw_version);
+ if (version2)
+ {
+ l = append_extra_arg(o, l, "recordXMLEscaping",
+ req->u.explain_request->recordPacking);
+ l = append_extra_arg(o, l, "recordPacking",
+ req->u.explain_request->packing);
+ }
+ else
+ l = append_extra_arg(o, l, "recordPacking",
+ req->u.explain_request->recordPacking);
l = append_extra_arg(o, l, "stylesheet",
req->u.explain_request->stylesheet);
}
+ for (ea = req->extra_args; ea; ea = ea->next)
+ l = append_extra_arg(o, l, ea->name, ea->value);
return res;
}
Z_SRW_PDU *sr = yaz_srw_get_core_ver(o, version);
sr->which = which;
- switch(which)
+ switch (which)
{
case Z_SRW_searchRetrieve_request:
sr->u.request = (Z_SRW_searchRetrieveRequest *)