Skip to content

Commit 6e7e909

Browse files
committed
Make it compatible with libxml2 >= 2.12.0
* libxml++/document.cc: * libxml++/dtd.cc: * libxml++/nodes/entitydeclaration.cc: * libxml++/nodes/entityreference.cc: * libxml++/validators/relaxngvalidator.cc: Modify #include directives. * libxml++/keepblanks.cc: Ignore deprecation of xmlKeepBlanksDefault(). * tests/saxparser_chunk_parsing_inconsistent_state/main.cc: Accept that MySaxParser::on_start_document() can be called before MySaxParser::on_error().
1 parent 13dfb0c commit 6e7e909

File tree

7 files changed

+18
-5
lines changed

7 files changed

+18
-5
lines changed

libxml++/document.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
#include <libxml/tree.h>
1818
#include <libxml/xinclude.h>
19+
#include <libxml/xmlsave.h>
1920
#include <libxml/parser.h> // XML_PARSE_NOXINCNODE, XML_PARSE_NOBASEFIX
2021

2122
#include <iostream>

libxml++/dtd.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include <libxml++/exceptions/parse_error.h>
99
#include <libxml++/io/istreamparserinputbuffer.h>
1010

11-
#include <libxml/tree.h>
11+
#include <libxml/parser.h>
1212

1313
namespace xmlpp
1414
{

libxml++/keepblanks.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@
55
* included with libxml++ as the file COPYING.
66
*/
77

8-
#include <libxml++/keepblanks.h>
8+
// xmlKeepBlanksDefault() is deprecated since libxml2 2.12.0.
9+
// Ignore deprecations here.
10+
#define XML_DEPRECATED
911

12+
#include <libxml++/keepblanks.h>
1013
#include <libxml/globals.h>
1114

1215
namespace xmlpp

libxml++/nodes/entitydeclaration.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66

77
#include <libxml++/nodes/entitydeclaration.h>
8-
#include <libxml/tree.h>
8+
#include <libxml/entities.h>
99

1010
namespace xmlpp
1111
{

libxml++/nodes/entityreference.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
#include <libxml++/nodes/entityreference.h>
88

9-
#include <libxml/tree.h>
9+
#include <libxml/entities.h>
1010

1111
namespace xmlpp
1212
{

libxml++/validators/relaxngvalidator.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "libxml++/parsers/domparser.h"
2323
#include "libxml++/relaxngschema.h"
2424

25+
#include <libxml/tree.h>
2526
#include <libxml/relaxng.h>
2627

2728
namespace xmlpp

tests/saxparser_chunk_parsing_inconsistent_state/main.cc

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,14 @@
2323

2424
class MySaxParser : public xmlpp::SaxParser
2525
{
26+
public:
27+
bool throw_on_start_doc = true;
28+
2629
protected:
2730
void on_start_document() override
2831
{
29-
throw std::runtime_error("some custom runtime exception");
32+
if (throw_on_start_doc)
33+
throw std::runtime_error("some custom runtime exception");
3034
}
3135
void on_error(const Glib::ustring& /* text */) override
3236
{
@@ -46,6 +50,9 @@ int main()
4650
bool exceptionThrown = false;
4751
try
4852
{
53+
// Depending on the libxml2 version, MySaxParser::on_start_document()
54+
// may or may not be called before MySaxParser::on_error().
55+
parser.throw_on_start_doc = false;
4956
parser.parse_chunk("<?");
5057
parser.finish_chunk_parsing();
5158
}
@@ -64,6 +71,7 @@ int main()
6471
exceptionThrown = false;
6572
try
6673
{
74+
parser.throw_on_start_doc = true;
6775
std::stringstream ss("<root></root>");
6876
parser.parse_stream(ss);
6977
}

0 commit comments

Comments
 (0)