[libxml++] Parser::initialize_context(): Call xmlCtxtUseOptions().



commit 58c9e7e82a63d226dd3d88611fde3450b93ae001
Author: Kjell Ahlstedt <kjell ahlstedt bredband net>
Date:   Wed Oct 10 16:02:46 2012 +0200

    Parser::initialize_context(): Call xmlCtxtUseOptions().
    
    * libxml++/parsers/parser.cc: initialize_context(): Call xmlCtxtUseOptions()
    instead of setting context_->validate and replaceEntities.
    xmlCtxtUseOptions() does that and more.

 ChangeLog                  |    8 ++++++++
 libxml++/parsers/parser.cc |   18 +++++++++++++-----
 2 files changed, 21 insertions(+), 5 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 5a8754b..7ee1472 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2012-10-10  Kjell Ahlstedt  <kjell ahlstedt bredband net>
+
+	Parser::initialize_context(): Call xmlCtxtUseOptions().
+
+	* libxml++/parsers/parser.cc: initialize_context(): Call xmlCtxtUseOptions()
+	instead of setting context_->validate and replaceEntities.
+	xmlCtxtUseOptions() does that and more.
+
 2.35.4:
 
 2012-08-28  Kjell Ahlstedt  <kjell ahlstedt bredband net>
diff --git a/libxml++/parsers/parser.cc b/libxml++/parsers/parser.cc
index 66e1d61..96250a5 100644
--- a/libxml++/parsers/parser.cc
+++ b/libxml++/parsers/parser.cc
@@ -107,8 +107,19 @@ void Parser::initialize_context()
   // could cause this to use the wrong settings:
   context_->linenumbers = 1; // TRUE - This is the default anyway.
 
-  //Turn on/off validation:
-  context_->validate = (validate_ ? 1 : 0);
+  //Turn on/off validation and entity substitution.
+  int options = context_->options;
+  if (validate_)
+    options |= XML_PARSE_DTDVALID;
+  else
+    options &= ~XML_PARSE_DTDVALID;
+
+  if (substitute_entities_)
+    options |= XML_PARSE_NOENT;
+  else
+    options &= ~XML_PARSE_NOENT;
+
+  xmlCtxtUseOptions(context_, options);
 
   Glib::Threads::Mutex::Lock lock(extra_parser_data_mutex);
   if (context_->sax && extra_parser_data[this].throw_parser_messages_)
@@ -130,9 +141,6 @@ void Parser::initialize_context()
   //Allow the callback_validity_*() methods to retrieve the C++ instance:
   context_->_private = this;
 
-  //Whether or not we substitute entities:
-  context_->replaceEntities = (substitute_entities_ ? 1 : 0);
-
   //Clear these temporary buffers too:
   extra_parser_data[this].parser_error_.erase();
   extra_parser_data[this].parser_warning_.erase();



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]