MOBI_RET mobi_xml_write_dcmeta_creator(xmlTextWriterPtr writer, const OPFcreator **creator, const char *name) {
    if (creator) {
        size_t i = 0;
        while (i < OPF_META_MAX_TAGS) {
            if (creator[i] == NULL || creator[i]->value == NULL) {
                break;
            }
            int xml_ret;
            xml_ret = xmlTextWriterStartElementNS(writer, BAD_CAST "dc", BAD_CAST name, NULL);
            if (xml_ret < 0) {
                debug_print("XML error: %i (creator value: %s)\n", xml_ret, creator[i]->value);
                return MOBI_XML_ERR;
            }
            if (creator[i]->role) {
                xml_ret = xmlTextWriterWriteAttributeNS(writer, BAD_CAST "opf", BAD_CAST "role", NULL, BAD_CAST creator[i]->role);
                if (xml_ret < 0) {
                    debug_print("XML error: %i (creator role: %s)\n", xml_ret, creator[i]->role);
                    return MOBI_XML_ERR;
                }
            }
            if (creator[i]->file_as) {
                xml_ret = xmlTextWriterWriteAttributeNS(writer, BAD_CAST "opf", BAD_CAST "file-as", NULL, BAD_CAST creator[i]->file_as);
                if (xml_ret < 0) {
                    debug_print("XML error: %i (creator file-as: %s)\n", xml_ret, creator[i]->file_as);
                    return MOBI_XML_ERR;
                }
            }
            xml_ret = xmlTextWriterWriteString(writer, BAD_CAST creator[i]->value);
            if (xml_ret < 0) {
                debug_print("XML error: %i (creator value: %s)\n", xml_ret, creator[i]->value);
                return MOBI_XML_ERR;
            }
            xml_ret = xmlTextWriterEndElement(writer);
            if (xml_ret < 0) {
                debug_print("XML error: %i (creator value: %s)\n", xml_ret, creator[i]->value);
                return MOBI_XML_ERR;
            }
            i++;
        }
    }
    return MOBI_SUCCESS;
}
MOBI_RET mobi_xml_write_dcmeta_creator(xmlTextWriterPtr writer, const OPFcreator **creator, const char *name) {
    if (creator) {
        size_t i = 0;
        while (i < OPF_META_MAX_TAGS) {
            if (creator[i] == NULL || creator[i]->value == NULL) {
                break;
            }
            int xml_ret;
            xml_ret = xmlTextWriterStartElementNS(writer, BAD_CAST "dc", BAD_CAST name, NULL);
            if (xml_ret < 0) {
                debug_print("XML error: %i (creator value: %s)\n", xml_ret, creator[i]->value);
                return MOBI_XML_ERR;
            }
            if (creator[i]->role) {
                xml_ret = xmlTextWriterWriteAttributeNS(writer, BAD_CAST "opf", BAD_CAST "role", NULL, BAD_CAST creator[i]->role);
                if (xml_ret < 0) {
                    debug_print("XML error: %i (creator role: %s)\n", xml_ret, creator[i]->role);
                    return MOBI_XML_ERR;
                }
            }
            if (creator[i]->file_as) {
                xml_ret = xmlTextWriterWriteAttributeNS(writer, BAD_CAST "opf", BAD_CAST "file-as", NULL, BAD_CAST creator[i]->file_as);
                if (xml_ret < 0) {
                    debug_print("XML error: %i (creator file-as: %s)\n", xml_ret, creator[i]->file_as);
                    return MOBI_XML_ERR;
                }
            }
            xml_ret = xmlTextWriterWriteString(writer, BAD_CAST creator[i]->value);
            if (xml_ret < 0) {
                debug_print("XML error: %i (creator value: %s)\n", xml_ret, creator[i]->value);
                return MOBI_XML_ERR;
            }
            xml_ret = xmlTextWriterEndElement(writer);
            if (xml_ret < 0) {
                debug_print("XML error: %i (creator value: %s)\n", xml_ret, creator[i]->value);
                return MOBI_XML_ERR;
            }
            i++;
        }
    }
    return MOBI_SUCCESS;
}