//--------------------------------------------------------------------------- int Policy::import_schema_from_memory(const char* buffer, int len, const std::string& save_name) { if (!buffer || !len) { error = "The schema does not exist"; return -1; } Schema s(no_https); xmlSetGenericErrorFunc(&s, &s.manage_generic_error); xmlDocPtr doc = xmlParseMemory(buffer, len); if (!doc) { // maybe put the errors from s.errors error = "The schema given cannot be parsed"; xmlSetGenericErrorFunc(NULL, NULL); return -1; } int ret = import_schema_from_doc(doc, save_name); xmlFreeDoc(doc); xmlSetGenericErrorFunc(NULL, NULL); return ret; }
//--------------------------------------------------------------------------- String Policy::import_schema(const std::string& filename) { Schematron s; xmlSetGenericErrorFunc(&s, &s.manage_generic_error); xmlDocPtr doc = xmlParseFile(filename.c_str()); if (!doc) { // maybe put the errors from s.errors return String(__T("The schema cannot be parsed")); } String ret = import_schema_from_doc(filename, doc); xmlFreeDoc(doc); saved = true; return ret; }
//--------------------------------------------------------------------------- String Policy::import_schema_from_memory(const std::string& filename, const char* buffer, int len) { if (!buffer || !len) return String(__T("The schematron does not exist")); Schematron s; xmlSetGenericErrorFunc(&s, &s.manage_generic_error); xmlDocPtr doc = xmlParseMemory(buffer, len); if (!doc) { // maybe put the errors from s.errors return String(__T("The schema given cannot be parsed")); } String ret = import_schema_from_doc(filename, doc); xmlFreeDoc(doc); saved = true; return ret; }
//--------------------------------------------------------------------------- int Policy::import_schema(const std::string& filename, const std::string& save_name) { Schema s(no_https); xmlSetGenericErrorFunc(&s, &s.manage_generic_error); xmlDocPtr doc = xmlParseFile(filename.c_str()); if (!doc) { // maybe put the errors from s.errors error = "The schema cannot be parsed"; xmlSetGenericErrorFunc(NULL, NULL); return -1; } int ret = import_schema_from_doc(doc, save_name); xmlFreeDoc(doc); xmlCleanupCharEncodingHandlers(); xmlSetGenericErrorFunc(NULL, NULL); return ret; }