+static int yaz_srw_record(ODR o, xmlNodePtr pptr, Z_SRW_record *rec,
+ void *client_data, const char *ns)
+{
+ if (o->direction == ODR_DECODE)
+ {
+ int pack = Z_SRW_recordPacking_string;
+ xmlNodePtr ptr;
+ rec->recordSchema = 0;
+ rec->recordData_buf = 0;
+ rec->recordData_len = 0;
+ rec->recordPosition = 0;
+ for (ptr = pptr->children; ptr; ptr = ptr->next)
+ {
+ char *spack = 0;
+
+ if (match_xsd_string(ptr, "recordSchema", o,
+ &rec->recordSchema))
+ ;
+ else if (match_xsd_string(ptr, "recordPacking", o, &spack))
+ {
+ if (pack && !strcmp(spack, "xml"))
+ pack = Z_SRW_recordPacking_XML;
+ if (pack && !strcmp(spack, "string"))
+ pack = Z_SRW_recordPacking_string;
+ }
+ else if (match_xsd_integer(ptr, "recordPosition", o,
+ &rec->recordPosition))
+ ;
+ else
+ {
+ if (pack == Z_SRW_recordPacking_XML)
+ match_xsd_XML_n(ptr, "recordData", o,
+ &rec->recordData_buf,
+ &rec->recordData_len);
+ if (pack == Z_SRW_recordPacking_string)
+ match_xsd_string_n(ptr, "recordData", o,
+ &rec->recordData_buf,
+ &rec->recordData_len);
+ }
+ }
+ rec->recordPacking = pack;
+ }
+ else if (o->direction == ODR_ENCODE)
+ {
+ xmlNodePtr ptr = pptr;
+ add_xsd_string(ptr, "recordSchema", rec->recordSchema);
+ switch(rec->recordPacking)
+ {
+ case Z_SRW_recordPacking_string:
+ add_xsd_string(ptr, "recordPacking", "string");
+ add_xsd_string_n(ptr, "recordData", rec->recordData_buf,
+ rec->recordData_len);
+ break;
+ case Z_SRW_recordPacking_XML:
+ add_xsd_string(ptr, "recordPacking", "xml");
+ add_XML_n(ptr, "recordData", rec->recordData_buf,
+ rec->recordData_len);
+ break;
+ }
+ add_xsd_integer(ptr, "recordPosition", rec->recordPosition);
+ }
+}
+