* Copyright (c) 2002-2003, Index Data.
* See the file LICENSE for details.
*
- * $Id: srw.h,v 1.5 2003-02-23 14:26:57 adam Exp $
+ * $Id: srw.h,v 1.6 2003-03-20 21:15:00 adam Exp $
*/
#ifndef YAZ_SRW_H
typedef struct {
char *recordSchema;
+ int recordPacking;
+#define Z_SRW_recordPacking_string 0
+#define Z_SRW_recordPacking_XML 1
char *recordData_buf;
int recordData_len;
int *recordPosition;
* Copyright (c) 1995-2003, Index Data
* See the file LICENSE for details.
*
- * $Id: seshigh.c,v 1.149 2003-03-18 13:34:36 adam Exp $
+ * $Id: seshigh.c,v 1.150 2003-03-20 21:15:00 adam Exp $
*/
/*
if (start <= rr.hits)
{
int j = 0;
+ int packing = Z_SRW_recordPacking_string;
if (start + number > rr.hits)
number = rr.hits - start + 1;
+ if (srw_req->recordPacking &&
+ !strcmp(srw_req->recordPacking, "xml"))
+ packing = Z_SRW_recordPacking_XML;
srw_res->records = (Z_SRW_record *)
odr_malloc(assoc->encode,
number * sizeof(*srw_res->records));
for (i = 0; i<number; i++)
{
int errcode;
+
+ srw_res->records[j].recordPacking = packing;
srw_res->records[j].recordData_buf = 0;
yaz_log(LOG_DEBUG, "srw_bend_fetch %d", i+start);
errcode = srw_bend_fetch(assoc, i+start, srw_req,
sr->u.request->sort.sortKeys = sortKeys;
}
sr->u.request->recordSchema = uri_val(p1, "recordSchema", o);
+ sr->u.request->recordPacking = uri_val(p1, "recordPacking", o);
uri_val_int(p1, "maximumRecords", o,
&sr->u.request->maximumRecords);
uri_val_int(p1, "startRecord", o,
* Copyright (c) 2002-2003, Index Data.
* See the file LICENSE for details.
*
- * $Id: srw.c,v 1.9 2003-03-18 13:34:37 adam Exp $
+ * $Id: srw.c,v 1.10 2003-03-20 21:15:00 adam Exp $
*/
#include <yaz/srw.h>
#include <libxml/parser.h>
#include <libxml/tree.h>
+static void add_XML_n(xmlNodePtr ptr, const char *elem, char *val, int len)
+{
+ if (val)
+ {
+ xmlDocPtr doc = xmlParseMemory(val,len);
+ if (doc)
+ {
+ xmlNodePtr c = xmlNewChild(ptr, 0, elem, 0);
+ xmlNodePtr t = xmlDocGetRootElement(doc);
+ xmlAddChild(c, xmlCopyNode(t,1));
+ xmlFreeDoc(doc);
+ }
+ }
+}
+
static void add_xsd_string_n(xmlNodePtr ptr, const char *elem, char *val,
int len)
{
{
xmlNodePtr rptr;
(*recs)[i].recordSchema = 0;
+ (*recs)[i].recordPacking = Z_SRW_recordPacking_string;
(*recs)[i].recordData_buf = 0;
(*recs)[i].recordData_len = 0;
(*recs)[i].recordPosition = 0;
{
xmlNodePtr rptr = xmlNewChild(pptr, 0, "record", 0);
add_xsd_string(rptr, "recordSchema", (*recs)[i].recordSchema);
- add_xsd_string_n(rptr, "recordData", (*recs)[i].recordData_buf,
- (*recs)[i].recordData_len);
+ switch((*recs)[i].recordPacking)
+ {
+ case Z_SRW_recordPacking_string:
+ add_xsd_string_n(rptr, "recordData", (*recs)[i].recordData_buf,
+ (*recs)[i].recordData_len);
+ break;
+ case Z_SRW_recordPacking_XML:
+ add_XML_n(rptr, "recordXML", (*recs)[i].recordData_buf,
+ (*recs)[i].recordData_len);
+ break;
+ }
add_xsd_integer(rptr, "recordPosition", (*recs)[i].recordPosition);
}
}