1 #include <anna/core/tracing/Logger.hpp>
2 #include <anna/core/tracing/TraceMethod.hpp>
3 #include <anna/config/defines.hpp>
5 #include <libxml/parser.h>
7 #include <anna/xml/DTD.hpp>
11 using namespace anna::xml;
15 if (a_handle != NULL) {
16 xmlFreeDtd (a_handle);
21 void DTD::initialize (const char* content)
22 throw (RuntimeException)
24 LOGMETHOD (TraceMethod tf ("anna::xml::DTD", "initialize", ANNA_FILE_LOCATION));
26 Guard guard (a_mutex);
28 if (a_handle != NULL) {
29 xmlFreeDtd (a_handle);
33 a_handle = parse (content);
36 void DTD::validate (_xmlValidCtxt* context, _xmlDoc* document) const
37 throw (RuntimeException)
40 throw RuntimeException ("'DTD::inicialize' was not called", ANNA_FILE_LOCATION);
43 throw RuntimeException ("Cannot validate with a NULL context", ANNA_FILE_LOCATION);
46 throw RuntimeException ("Cannot validate a NULL XML document", ANNA_FILE_LOCATION);
48 if (xmlValidateDtd (context, document, a_handle) == 0) {
49 string msg ("XML Document");
53 msg += document->name;
55 else if (document->URL) {
57 msg += (const char*) document->URL;
60 msg += " | Does not comply the DTD especification ";
61 throw RuntimeException (msg, ANNA_FILE_LOCATION);