From 65800e2dcdfbb5aff410ce9e92aec6b42aabeba7 Mon Sep 17 00:00:00 2001 From: "John M. Penn" Date: Fri, 10 Nov 2017 13:42:39 -0600 Subject: [PATCH] If XML_CATALOG_FILES env variable is not set, parse xml files without validation. Ref #514 --- .../data_products/DPX/DPM/DPM_parse_tree.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/trick_source/data_products/DPX/DPM/DPM_parse_tree.cpp b/trick_source/data_products/DPX/DPM/DPM_parse_tree.cpp index 1dbaa6d4..c98d2692 100644 --- a/trick_source/data_products/DPX/DPM/DPM_parse_tree.cpp +++ b/trick_source/data_products/DPX/DPM/DPM_parse_tree.cpp @@ -1,5 +1,6 @@ #include +#include int DPM_parse_tree::Initialize(const char *XMLFileName) { @@ -23,7 +24,16 @@ int DPM_parse_tree::Initialize(const char *XMLFileName) { exit(0); } - doc = xmlCtxtReadFile( parser_context, XMLFileName, NULL, 0 ); + const char* xml_catalog_files = getenv("XML_CATALOG_FILES"); + if (xml_catalog_files != NULL) { + doc = xmlCtxtReadFile( parser_context, XMLFileName, NULL, XML_PARSE_DTDVALID ); + } else { + std::cerr << std::endl + << "The XML_CATALOG_FILES environment variable is not set." << std::endl + << "So, \"" << XMLFileName << "\" cannot be validated against it's DTD." << std::endl + << "It will therefore be parsed without validation." << std::endl << std::endl; + doc = xmlCtxtReadFile( parser_context, XMLFileName, NULL, 0 ); + } if (doc == NULL) { std::cerr << "ERROR: Parse of XML file \"" << XMLFileName << "\"" << " failed." << std::endl;