1 // ANNA - Anna is Not Nothingness Anymore //
3 // (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo //
5 // See project site at http://redmine.teslayout.com/projects/anna-suite //
6 // See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE //
9 #include <anna/core/tracing/Logger.hpp>
10 #include <anna/core/tracing/TraceMethod.hpp>
11 #include <anna/config/defines.hpp>
13 #include <libxml/parser.h>
15 #include <anna/xml/DTD.hpp>
19 using namespace anna::xml;
22 if(a_handle != NULL) {
28 void DTD::initialize(const char* content)
29 throw(RuntimeException) {
30 LOGMETHOD(TraceMethod tf("anna::xml::DTD", "initialize", ANNA_FILE_LOCATION));
33 if(a_handle != NULL) {
38 a_handle = parse(content);
41 void DTD::validate(_xmlValidCtxt* context, _xmlDoc* document) const
42 throw(RuntimeException) {
44 throw RuntimeException("'DTD::inicialize' was not called", ANNA_FILE_LOCATION);
47 throw RuntimeException("Cannot validate with a NULL context", ANNA_FILE_LOCATION);
50 throw RuntimeException("Cannot validate a NULL XML document", ANNA_FILE_LOCATION);
52 if(xmlValidateDtd(context, document, a_handle) == 0) {
53 string msg("XML Document");
57 msg += document->name;
58 } else if(document->URL) {
60 msg += (const char*) document->URL;
63 msg += " | Does not comply the DTD especification ";
64 throw RuntimeException(msg, ANNA_FILE_LOCATION);