MOBI_RET mobi_xml_write_xmeta_srp(xmlTextWriterPtr writer, const OPFsrp **srp) {
    if (srp) {
        size_t i = 0;
        while (i < OPF_META_MAX_TAGS) {
            if (srp[i] == NULL || srp[i]->value == NULL) {
                break;
            }
            int xml_ret;
            xml_ret = xmlTextWriterStartElement(writer, BAD_CAST "srp");
            if (xml_ret < 0) {
                debug_print("XML error: %i (srp value: %s)\n", xml_ret, srp[i]->value);
                return MOBI_XML_ERR;
            }
            if (srp[i]->currency) {
                xml_ret = xmlTextWriterWriteAttribute(writer, BAD_CAST "currency", BAD_CAST srp[i]->currency);
                if (xml_ret < 0) {
                    debug_print("XML error: %i (srp currency: %s)\n", xml_ret, srp[i]->currency);
                    return MOBI_XML_ERR;
                }
            }
            xml_ret = xmlTextWriterWriteString(writer, BAD_CAST srp[i]->value);
            if (xml_ret < 0) {
                debug_print("XML error: %i (srp value: %s)\n", xml_ret, srp[i]->value);
                return MOBI_XML_ERR;
            }
            xml_ret = xmlTextWriterEndElement(writer);
            if (xml_ret < 0) {
                debug_print("XML error: %i (srp value: %s)\n", xml_ret, srp[i]->value);
                return MOBI_XML_ERR;
            }
            i++;
        }
    }
    return MOBI_SUCCESS;
}
MOBI_RET mobi_xml_write_xmeta_srp(xmlTextWriterPtr writer, const OPFsrp **srp) {
    if (srp) {
        size_t i = 0;
        while (i < OPF_META_MAX_TAGS) {
            if (srp[i] == NULL || srp[i]->value == NULL) {
                break;
            }
            int xml_ret;
            xml_ret = xmlTextWriterStartElement(writer, BAD_CAST "srp");
            if (xml_ret < 0) {
                debug_print("XML error: %i (srp value: %s)\n", xml_ret, srp[i]->value);
                return MOBI_XML_ERR;
            }
            if (srp[i]->currency) {
                xml_ret = xmlTextWriterWriteAttribute(writer, BAD_CAST "currency", BAD_CAST srp[i]->currency);
                if (xml_ret < 0) {
                    debug_print("XML error: %i (srp currency: %s)\n", xml_ret, srp[i]->currency);
                    return MOBI_XML_ERR;
                }
            }
            xml_ret = xmlTextWriterWriteString(writer, BAD_CAST srp[i]->value);
            if (xml_ret < 0) {
                debug_print("XML error: %i (srp value: %s)\n", xml_ret, srp[i]->value);
                return MOBI_XML_ERR;
            }
            xml_ret = xmlTextWriterEndElement(writer);
            if (xml_ret < 0) {
                debug_print("XML error: %i (srp value: %s)\n", xml_ret, srp[i]->value);
                return MOBI_XML_ERR;
            }
            i++;
        }
    }
    return MOBI_SUCCESS;
}