#include #include #include #include #include using namespace std; using namespace anna; using namespace anna::xml; DTD::~DTD () { if (a_handle != NULL) { xmlFreeDtd (a_handle); a_handle = NULL; } } void DTD::initialize (const char* content) noexcept(false) { LOGMETHOD (TraceMethod tf ("anna::xml::DTD", "initialize", ANNA_FILE_LOCATION)); Guard guard (a_mutex); if (a_handle != NULL) { xmlFreeDtd (a_handle); a_handle = NULL; } a_handle = parse (content); } void DTD::validate (_xmlValidCtxt* context, _xmlDoc* document) const noexcept(false) { if (a_handle == NULL) throw RuntimeException ("'DTD::inicialize' was not called", ANNA_FILE_LOCATION); if (context == NULL) throw RuntimeException ("Cannot validate with a NULL context", ANNA_FILE_LOCATION); if (document == NULL) throw RuntimeException ("Cannot validate a NULL XML document", ANNA_FILE_LOCATION); if (xmlValidateDtd (context, document, a_handle) == 0) { string msg ("XML Document"); if (document->name) { msg += ": "; msg += document->name; } else if (document->URL) { msg += ": "; msg += (const char*) document->URL; } msg += " | Does not comply the DTD especification "; throw RuntimeException (msg, ANNA_FILE_LOCATION); } }