char *yaz_negotiate_sru_version(char *input_ver)
{
if (!input_ver)
- input_ver = "1.1";
-
+ return "2.0";
if (!strcmp(input_ver, "1.1"))
return "1.1";
- return "1.2"; /* our latest supported version */
+ if (!strncmp(input_ver, "1.", 2))
+ return "1.2";
+ if (!strncmp(input_ver, "2.", 2))
+ return "2.0";
+ return 0;
}
static int yaz_srw_record(ODR o, xmlNodePtr pptr, Z_SRW_record *rec,
Z_SRW_extra_record **extra,
- void *client_data, const char *ns)
+ void *client_data)
{
if (o->direction == ODR_DECODE)
{
char *spack = 0;
xmlNodePtr ptr;
+#ifdef Z_SRW_packed
+ rec->packing = 0;
+#endif
rec->recordSchema = 0;
rec->recordData_buf = 0;
rec->recordData_len = 0;
static int yaz_srw_records(ODR o, xmlNodePtr pptr, Z_SRW_record **recs,
Z_SRW_extra_record ***extra,
- int *num, void *client_data, const char *ns)
+ int *num, void *client_data)
{
if (o->direction == ODR_DECODE)
{
if (ptr->type == XML_ELEMENT_NODE &&
!xmlStrcmp(ptr->name, BAD_CAST "record"))
{
- yaz_srw_record(o, ptr, *recs + i, *extra + i, client_data, ns);
+ yaz_srw_record(o, ptr, *recs + i, *extra + i, client_data);
i++;
}
}
xmlNodePtr rptr = xmlNewChild(pptr, 0, BAD_CAST "record",
0);
yaz_srw_record(o, rptr, (*recs)+i, (*extra ? *extra + i : 0),
- client_data, ns);
+ client_data);
}
}
return 0;
if (method->type != XML_ELEMENT_NODE)
return -1;
- *p = yaz_srw_get_core_v_1_1(o);
+ *p = yaz_srw_get_core_v_2_0(o);
if (!xmlStrcmp(method->name, BAD_CAST "searchRetrieveRequest"))
{
req->maximumRecords = 0;
req->recordSchema = 0;
req->recordPacking = 0;
+ req->packing = 0;
req->recordXPath = 0;
req->resultSetTTL = 0;
req->stylesheet = 0;
else if (match_element(ptr, "records"))
yaz_srw_records(o, ptr, &res->records,
&res->extra_records,
- &res->num_records, client_data, ns);
+ &res->num_records, client_data);
else if (match_xsd_integer(ptr, "nextRecordPosition", o,
&res->nextRecordPosition))
;
req = (*p)->u.explain_request = (Z_SRW_explainRequest *)
odr_malloc(o, sizeof(*req));
req->recordPacking = 0;
+ req->packing = 0;
req->database = 0;
req->stylesheet = 0;
for (; ptr; ptr = ptr->next)
;
else if (match_element(ptr, "record"))
yaz_srw_record(o, ptr, &res->record, &res->extra_record,
- client_data, ns);
+ client_data);
else if (match_element(ptr, "diagnostics"))
yaz_srw_diagnostics(o, ptr, &res->diagnostics,
&res->num_diagnostics,
Z_SRW_PDU **p = handler_data;
xmlNsPtr ns_srw;
xmlNodePtr ptr = 0;
-
+ int version2 = !(*p)->srw_version ||
+ strcmp((*p)->srw_version, "2.") > 0;
if ((*p)->which == Z_SRW_searchRetrieve_request)
{
Z_SRW_searchRetrieveRequest *req = (*p)->u.request;
const char *queryType = req->queryType;
+ if (version2)
+ ns = "http://docs.oasis-open.org/ns/search-ws/sruRequest";
ptr = xmlNewChild(pptr, 0, BAD_CAST "searchRetrieveRequest", 0);
ns_srw = xmlNewNs(ptr, BAD_CAST ns, BAD_CAST "zs");
xmlSetNs(ptr, ns_srw);
- if ((*p)->srw_version)
+ if (!version2)
add_xsd_string(ptr, "version", (*p)->srw_version);
- if (strcmp((*p)->srw_version, "2.") > 0)
+ if (version2)
{
if (queryType)
add_xsd_string(ptr, "queryType", queryType);
else if ((*p)->which == Z_SRW_searchRetrieve_response)
{
Z_SRW_searchRetrieveResponse *res = (*p)->u.response;
+ if (version2)
+ ns = "http://docs.oasis-open.org/ns/search-ws/sruResponse";
ptr = xmlNewChild(pptr, 0, BAD_CAST "searchRetrieveResponse", 0);
ns_srw = xmlNewNs(ptr, BAD_CAST ns, BAD_CAST "zs");
xmlSetNs(ptr, ns_srw);
- if ((*p)->srw_version)
+ if (!version2)
add_xsd_string(ptr, "version", (*p)->srw_version);
add_xsd_integer(ptr, "numberOfRecords", res->numberOfRecords);
add_xsd_string(ptr, "resultSetId", res->resultSetId);
xmlNodePtr rptr = xmlNewChild(ptr, 0, BAD_CAST "records", 0);
yaz_srw_records(o, rptr, &res->records, &res->extra_records,
&res->num_records,
- client_data, ns);
+ client_data);
}
add_xsd_integer(ptr, "nextRecordPosition",
res->nextRecordPosition);
ns_srw = xmlNewNs(ptr, BAD_CAST ns, BAD_CAST "zs");
xmlSetNs(ptr, ns_srw);
- add_xsd_string(ptr, "version", (*p)->srw_version);
+ if (!version2)
+ add_xsd_string(ptr, "version", (*p)->srw_version);
add_xsd_string(ptr, "recordPacking", req->recordPacking);
add_xsd_string(ptr, "stylesheet", req->stylesheet);
add_xsd_string(ptr, "database", req->database);
{
xmlNodePtr ptr1 = xmlNewChild(ptr, 0, BAD_CAST "record", 0);
yaz_srw_record(o, ptr1, &res->record, &res->extra_record,
- client_data, ns);
+ client_data);
}
if (res->num_diagnostics)
{
{
Z_SRW_scanRequest *req = (*p)->u.scan_request;
const char *queryType = req->queryType;
+ if (version2)
+ ns = "http://docs.oasis-open.org/ns/search-ws/scan";
ptr = xmlNewChild(pptr, 0, BAD_CAST "scanRequest", 0);
ns_srw = xmlNewNs(ptr, BAD_CAST ns, BAD_CAST "zs");
xmlSetNs(ptr, ns_srw);
- add_xsd_string(ptr, "version", (*p)->srw_version);
+ if (!version2)
+ add_xsd_string(ptr, "version", (*p)->srw_version);
if (strcmp((*p)->srw_version, "2.") > 0)
{
else if ((*p)->which == Z_SRW_scan_response)
{
Z_SRW_scanResponse *res = (*p)->u.scan_response;
+ if (version2)
+ ns = "http://docs.oasis-open.org/ns/search-ws/scan";
ptr = xmlNewChild(pptr, 0, BAD_CAST "scanResponse", 0);
ns_srw = xmlNewNs(ptr, BAD_CAST ns, BAD_CAST "zs");
xmlSetNs(ptr, ns_srw);
- add_xsd_string(ptr, "version", (*p)->srw_version);
+ if (!version2)
+ add_xsd_string(ptr, "version", (*p)->srw_version);
if (res->num_terms)
{
if (method->type != XML_ELEMENT_NODE)
return -1;
- *p = yaz_srw_get_core_v_1_1(o);
+ *p = yaz_srw_get_core_v_2_0(o);
if (!xmlStrcmp(method->name, BAD_CAST "updateRequest"))
{
{
req->record = yaz_srw_get_record(o);
yaz_srw_record(o, ptr, req->record, &req->extra_record,
- client_data, ns_ucp_str);
+ client_data);
}
else if (match_xsd_string(ptr, "stylesheet", o,
&req->stylesheet))
{
res->record = yaz_srw_get_record(o);
yaz_srw_record(o, ptr, res->record, &res->extra_record,
- client_data, ns_ucp_str);
+ client_data);
}
else if (match_element(ptr, "diagnostics"))
yaz_srw_diagnostics(o, ptr, &res->diagnostics,
xmlNodePtr rptr = xmlNewChild(ptr, 0, BAD_CAST "record", 0);
xmlSetNs(rptr, ns_srw);
yaz_srw_record(o, rptr, req->record, &req->extra_record,
- client_data, ns_ucp_str);
+ client_data);
}
if (req->extraRequestData_len)
{
xmlNodePtr rptr = xmlNewChild(ptr, 0, BAD_CAST "record", 0);
xmlSetNs(rptr, ns_srw);
yaz_srw_record(o, rptr, res->record, &res->extra_record,
- client_data, ns_ucp_str);
+ client_data);
}
if (res->num_diagnostics)
{
const char *p0 = hreq->path, *p1;
int ret = -1;
- static Z_SOAP_Handler soap_handlers[4] = {
+ static Z_SOAP_Handler soap_handlers[5] = {
#if YAZ_HAVE_XML2
{ YAZ_XMLNS_SRU_v1_1, 0, (Z_SOAP_fun) yaz_srw_codec },
{ YAZ_XMLNS_SRU_v1_0, 0, (Z_SOAP_fun) yaz_srw_codec },
{ YAZ_XMLNS_UPDATE_v0_9, 0, (Z_SOAP_fun) yaz_ucp_codec },
+ { YAZ_XMLNS_SRU_v2_mask, 0, (Z_SOAP_fun) yaz_srw_codec },
#endif
{0, 0, 0}
};
*srw_pdu = (Z_SRW_PDU*) (*soap_package)->u.generic->p;
yaz_srw_decodeauth(*srw_pdu, hreq, 0, 0, decode);
+ if ((*soap_package)->u.generic->no == 3) /* SRU 2 ! */
+ (*soap_package)->u.generic->no = 0;
if ((*srw_pdu)->which == Z_SRW_searchRetrieve_request &&
(*srw_pdu)->u.request->database == 0)
(*srw_pdu)->u.request->database = db;
char *scanClause = 0;
char *recordXPath = 0;
char *recordSchema = 0;
- char *recordPacking = "xml"; /* xml packing is default for SRU */
+ char *recordXMLEscaping = 0;
+ char *recordPacking = 0;
char *maximumRecords = 0;
char *startRecord = 0;
char *maximumTerms = 0;
recordSchema = v;
else if (!strcmp(n, "recordPacking"))
recordPacking = v;
+ else if (!strcmp(n, "recordXMLEscaping"))
+ recordXMLEscaping = v;
else if (!strcmp(n, "version"))
version = v;
else if (!strcmp(n, "scanClause"))
}
}
}
- if (!version)
- {
- if (uri_name)
- yaz_add_srw_diagnostic(
- decode, diag, num_diag,
- YAZ_SRW_MANDATORY_PARAMETER_NOT_SUPPLIED, "version");
- version = "1.1";
- }
-
+ if (!operation && query)
+ operation = "searchRetrieve";
version = yaz_negotiate_sru_version(version);
if (!version)
{ /* negotiation failed. */
yaz_add_srw_diagnostic(decode, diag, num_diag,
- YAZ_SRW_UNSUPP_VERSION, "1.2");
- version = "1.2";
+ YAZ_SRW_UNSUPP_VERSION, "2.0");
+ version = "2.0";
}
-
if (!operation)
{
if (uri_name)
YAZ_SRW_MANDATORY_PARAMETER_NOT_SUPPLIED, "operation");
operation = "explain";
}
+ if (strcmp(version, "2.0"))
+ {
+ if (recordXMLEscaping)
+ {
+ yaz_add_srw_diagnostic(decode, diag, num_diag,
+ YAZ_SRW_UNSUPP_PARAMETER,
+ "recordXMLEscaping");
+
+ }
+ recordXMLEscaping = recordPacking;
+ recordPacking = "packed";
+ }
+ if (!recordXMLEscaping)
+ recordXMLEscaping = "xml";
if (!strcmp(operation, "searchRetrieve"))
{
Z_SRW_PDU *sr = yaz_srw_get(decode, Z_SRW_searchRetrieve_request);
}
sr->u.request->recordXPath = recordXPath;
sr->u.request->recordSchema = recordSchema;
- sr->u.request->recordPacking = recordPacking;
+ sr->u.request->recordPacking = recordXMLEscaping;
+ sr->u.request->packing = recordPacking;
sr->u.request->stylesheet = stylesheet;
yaz_sru_decode_integer(decode, "maximumRecords", maximumRecords,
sr->extra_args = extra_args;
yaz_srw_decodeauth(sr, hreq, username, password, decode);
*srw_pdu = sr;
- sr->u.explain_request->recordPacking = recordPacking;
+ sr->u.explain_request->recordPacking = recordXMLEscaping;
+ sr->u.explain_request->packing = recordPacking;
sr->u.explain_request->database = db;
sr->u.explain_request->stylesheet = stylesheet;
return p;
}
-Z_SRW_PDU *yaz_srw_get_core_v_1_1(ODR o)
+Z_SRW_PDU *yaz_srw_get_core_v_2_0(ODR o)
{
- return yaz_srw_get_core_ver(o, "1.1");
+ return yaz_srw_get_core_ver(o, "2.0");
}
Z_SRW_PDU *yaz_srw_get(ODR o, int which)
{
- return yaz_srw_get_pdu(o, which, "1.1");
+ return yaz_srw_get_pdu(o, which, "2.0");
}
Z_SRW_PDU *yaz_srw_get_pdu(ODR o, int which, const char *version)
static int yaz_get_sru_parms(const Z_SRW_PDU *srw_pdu, ODR encode,
char **name, char **value, int max_names)
{
+ int version2 = strcmp(srw_pdu->srw_version, "2.") > 0;
int i = 0;
char *queryType;
- yaz_add_name_value_str(encode, name, value, &i, "version", srw_pdu->srw_version);
+ if (!version2)
+ yaz_add_name_value_str(encode, name, value, &i, "version", srw_pdu->srw_version);
name[i] = "operation";
switch (srw_pdu->which)
{
case Z_SRW_searchRetrieve_request:
- value[i++] = "searchRetrieve";
+ if (!version2)
+ value[i++] = "searchRetrieve";
queryType = srw_pdu->u.request->queryType;
- if (strcmp(srw_pdu->srw_version, "2.") > 0)
+ if (version2)
{
yaz_add_name_value_str(encode, name, value, &i, "queryType",
queryType);
case Z_SRW_scan_request:
value[i++] = "scan";
queryType = srw_pdu->u.request->queryType;
- if (strcmp(srw_pdu->srw_version, "2.") > 0)
+ if (version2)
{
if (queryType && strcmp(queryType, "cql"))
yaz_add_name_value_str(encode, name, value, &i, "queryType",