Skip to content

Commit 4947181

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 5f53717 commit 4947181

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
#include <sstream>
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
@@ -24,10 +24,14 @@
2424

2525
class MySaxParser : public xmlpp::SaxParser
2626
{
27+
public:
28+
bool throw_on_start_doc = true;
29+
2730
protected:
2831
void on_start_document() override
2932
{
30-
throw std::runtime_error("some custom runtime exception");
33+
if (throw_on_start_doc)
34+
throw std::runtime_error("some custom runtime exception");
3135
}
3236
void on_error(const xmlpp::ustring& /* text */) override
3337
{
@@ -43,6 +47,9 @@ int main()
4347
bool exceptionThrown = false;
4448
try
4549
{
50+
// Depending on the libxml2 version, MySaxParser::on_start_document()
51+
// may or may not be called before MySaxParser::on_error().
52+
parser.throw_on_start_doc = false;
4653
parser.parse_chunk("<?");
4754
parser.finish_chunk_parsing();
4855
}
@@ -61,6 +68,7 @@ int main()
6168
exceptionThrown = false;
6269
try
6370
{
71+
parser.throw_on_start_doc = true;
6472
std::stringstream ss("<root></root>");
6573
parser.parse_stream(ss);
6674
}

0 commit comments

Comments
 (0)