forked from gentoo/gentoo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ovaldi-5.10.1.4-xerces3.patch
283 lines (259 loc) · 13 KB
/
ovaldi-5.10.1.4-xerces3.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
--- src/XmlProcessor.h.old 2011-08-18 14:35:41.608703233 +0200
+++ src/XmlProcessor.h 2011-08-18 14:39:21.835597094 +0200
@@ -38,14 +38,17 @@
#include <string>
// required xerces includes
-#include <xercesc/dom/DOMBuilder.hpp>
#include <xercesc/dom/DOMDocument.hpp>
#include <xercesc/dom/DOMErrorHandler.hpp>
#include <xercesc/dom/DOMError.hpp>
// for entity resolver
-#include <xercesc/dom/DOMEntityResolver.hpp>
-#include <xercesc/dom/DOMInputSource.hpp>
+
+#include <xercesc/dom/DOMImplementationRegistry.hpp>
+#include <xercesc/dom/DOMLSParser.hpp>
+#include <xercesc/sax/EntityResolver.hpp>
+#include <xercesc/sax/InputSource.hpp>
+#include <xercesc/sax2/SAX2XMLReader.hpp>
#include "Exception.h"
@@ -53,12 +56,14 @@
This class extends the default DOMEntityResolver and implments the resolve entity method
to support
*/
-class DataDirResolver : public xercesc::DOMEntityResolver {
+class DataDirResolver : public xercesc::EntityResolver {
public:
/**
*
*/
- xercesc::DOMInputSource *resolveEntity (const XMLCh *const publicId, const XMLCh *const systemId, const XMLCh *const baseURI);
+// xercesc::DOMInputSource *resolveEntity (const XMLCh *const publicId, const XMLCh *const systemId, const XMLCh *const baseURI);
+ xercesc::InputSource *resolveEntity (const XMLCh *const publicId, const XMLCh *const systemId);
+ xercesc::DOMLSInput *resolveEntity (const XMLCh *const publicId, const XMLCh *const systemId, const XMLCh *const baseURI);
};
/**
@@ -144,7 +149,7 @@
* owns the documents it builds. Users must manually destroy
* those documents.
*/
- xercesc::DOMBuilder *parserWithCallerAdoption;
+ xercesc::DOMLSParser *parserWithCallerAdoption;
/**
* This parser doesn't have user-adoption switched on, so it
@@ -156,7 +161,7 @@
* appear to ever be switched off. So to make sure this isn't
* leaking memory, I have created separate parsers.
*/
- xercesc::DOMBuilder *parser;
+ xercesc::DOMLSParser *parser;
/** The entity resolver for both parsers. */
DataDirResolver resolver;
--- src/probes/independent/XmlFileContentProbe.cpp.old 2010-10-22 14:49:22.000000000 +0200
+++ src/probes/independent/XmlFileContentProbe.cpp 2010-10-22 14:51:39.000000000 +0200
@@ -419,12 +419,24 @@
return new DummyEntityResolver::DoNothingBinInputStream();
}
+#if XERCES_VERSION_MAJOR < 3
unsigned int DummyEntityResolver::DoNothingBinInputStream::curPos() const
+#else
+const XMLCh* DummyEntityResolver::DoNothingBinInputStream::getContentType() const
+{
+ return NULL;
+}
+XMLFilePos DummyEntityResolver::DoNothingBinInputStream::curPos() const
+#endif
{
return 0;
}
+#if XERCES_VERSION_MAJOR < 3
unsigned int DummyEntityResolver::DoNothingBinInputStream::readBytes(XMLByte *const /*toFill*/, const unsigned int /*maxToRead*/)
+#else
+XMLSize_t DummyEntityResolver::DoNothingBinInputStream::readBytes(XMLByte *const toFill, XMLSize_t maxToRead)
+#endif
{
return 0;
}
--- src/probes/independent/XmlFileContentProbe.h.old 2010-10-22 14:55:47.000000000 +0200
+++ src/probes/independent/XmlFileContentProbe.h 2010-10-22 14:57:00.000000000 +0200
@@ -134,8 +134,14 @@
class DoNothingBinInputStream : public BinInputStream
{
public:
+#if XERCES_VERSION_MAJOR < 3
virtual unsigned int curPos() const;
virtual unsigned int readBytes(XMLByte *const toFill, const unsigned int maxToRead);
+#else
+ virtual XMLFilePos curPos() const;
+ virtual const XMLCh* getContentType() const;
+ virtual XMLSize_t readBytes(XMLByte *const toFill, XMLSize_t maxToRead);
+#endif
};
};
--- src/XmlCommon.cpp.old
+++ src/XmlCommon.cpp
@@ -546,7 +546,11 @@ void XmlCommon::AddSchemaLocation(XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *do
string XmlCommon::GetNamespace(DOMElement *element) {
string xmlns = "";
+#if XERCES_VERSION_MAJOR < 3
xmlns = XmlCommon::ToString(element->getTypeInfo()->getNamespace());
+#else
+ xmlns = XmlCommon::ToString(element->getSchemaTypeInfo()->getTypeNamespace());
+#endif
if (xmlns.compare("") == 0) {
xmlns = "";
}
--- src/XmlProcessor.cpp.old 2013-01-14 15:16:14.000000000 +0100
+++ src/XmlProcessor.cpp 2013-01-14 15:19:20.000000000 +0100
@@ -35,7 +35,6 @@
// for dom Writer
#include <xercesc/dom/DOMImplementation.hpp>
#include <xercesc/dom/DOMImplementationLS.hpp>
-#include <xercesc/dom/DOMWriter.hpp>
#include <xercesc/framework/StdOutFormatTarget.hpp>
#include <xercesc/framework/LocalFileFormatTarget.hpp>
#include <xercesc/util/XMLUni.hpp>
@@ -50,11 +49,26 @@
using namespace std;
using namespace xercesc;
+#if XERCES_VERSION_MAJOR < 3
+#define SetParameter(serializer,n,v) if (serializer->canSetFeature(n,v)) serializer->setFeature(n,v)
+#else
+#define SetParameter(serializer,n,v) if (serializer->getDomConfig()->canSetParameter(n,v)) serializer->getDomConfig()->setParameter(n,v)
+#endif
+
//****************************************************************************************//
// DataDirResolver Class //
//****************************************************************************************//
-
+#if XERCES_VERSION_MAJOR < 3
DOMInputSource* DataDirResolver::resolveEntity (const XMLCh *const /*publicId*/, const XMLCh *const systemId, const XMLCh *const /*baseURI*/) {
+#else
+InputSource* DataDirResolver::resolveEntity(const XMLCh* publicId, const XMLCh* systemId)
+{
+ return NULL;
+ //return DataDirResolver::resolveEntity (publicId, systemId, NULL);
+}
+
+DOMLSInput* DataDirResolver::resolveEntity (const XMLCh *const publicId, const XMLCh *const systemId, const XMLCh *const baseURI) {
+#endif
string path = "";
size_t last;
string schemapath = Common::GetSchemaPath();
@@ -127,7 +141,7 @@
parserWithCallerAdoption = makeParser(schemaLocation);
// add one extra feature on this parser to prevent it from
// taking ownership of its documents.
- parserWithCallerAdoption->setFeature(XMLUni::fgXercesUserAdoptsDOMDocument, true);
+ SetParameter(parserWithCallerAdoption, XMLUni::fgXercesUserAdoptsDOMDocument, true);
} catch (const XMLException& toCatch) {
string errMsg = "Error: An error occured durring initialization of the xml utilities:\n";
@@ -156,32 +170,40 @@
XMLPlatformUtils::Terminate();
}
-DOMBuilder *XmlProcessor::makeParser(const string &schemaLocation) {
+DOMLSParser *XmlProcessor::makeParser(const string &schemaLocation) {
// Instantiate the DOM parser.
static const XMLCh gLS[] = { chLatin_L, chLatin_S, chNull };
DOMImplementation *impl = DOMImplementationRegistry::getDOMImplementation(gLS);
- DOMBuilder *parser = ((DOMImplementationLS*)impl)->createDOMBuilder(DOMImplementationLS::MODE_SYNCHRONOUS, 0);
+#if XERCES_VERSION_MAJOR < 3
+ DOMLSParser *parser = ((DOMImplementationLS*)impl)->createDOMLSParser(DOMImplementationLS::MODE_SYNCHRONOUS, 0);
+#else
+ DOMLSParser *parser = ((DOMImplementationLS*)impl)->createLSParser(DOMImplementationLS::MODE_SYNCHRONOUS, 0);
+#endif
///////////////////////////////////////////////////////
// Set features on the builder
///////////////////////////////////////////////////////
- parser->setFeature(XMLUni::fgDOMComments, false); // Discard Comment nodes in the document.
- parser->setFeature(XMLUni::fgDOMDatatypeNormalization, true); // Let the validation process do its datatype normalization that is defined in the used schema language.
- parser->setFeature(XMLUni::fgDOMNamespaces, true); // Perform Namespace processing
- parser->setFeature(XMLUni::fgDOMValidation, true); // Report all validation errors.
- parser->setFeature(XMLUni::fgXercesSchema, true); // Enable the parser's schema support.
- parser->setFeature(XMLUni::fgXercesSchemaFullChecking, true); // Enable full schema constraint checking, including checking which may be time-consuming or memory intensive. Currently, particle unique attribution constraint checking and particle derivation restriction checking are controlled by this option.
- parser->setFeature(XMLUni::fgXercesValidationErrorAsFatal, true); // The parser will treat validation error as fatal and will exit
- parser->setFeature(XMLUni::fgXercesDOMHasPSVIInfo, true); // Enable storing of PSVI information in element and attribute nodes.
+ SetParameter(parser, XMLUni::fgDOMComments, false); // Discard Comment nodes in the document.
+ SetParameter(parser, XMLUni::fgDOMDatatypeNormalization, true); // Let the validation process do its datatype normalization that is defined in the used schema language.
+ SetParameter(parser, XMLUni::fgDOMNamespaces, true); // Perform Namespace processing
+ SetParameter(parser, XMLUni::fgDOMValidate, true); // Report all validation errors.
+ SetParameter(parser, XMLUni::fgXercesSchema, true); // Enable the parser's schema support.
+ SetParameter(parser, XMLUni::fgXercesSchemaFullChecking, true); // Enable full schema constraint checking, including checking which may be time-consuming or memory intensive. Currently, particle unique attribution constraint checking and particle derivation restriction checking are controlled by this option.
+ SetParameter(parser, XMLUni::fgXercesValidationErrorAsFatal, true); // The parser will treat validation error as fatal and will exit
+ SetParameter(parser, XMLUni::fgXercesDOMHasPSVIInfo, true); // Enable storing of PSVI information in element and attribute nodes.
///////////////////////////////////////////////////////
//****************************************************************************************//
// The following code was added to handle air-gap operation //
//****************************************************************************************//
/* Look for XML schemas in local directory instead of Internet */
+#if XERCES_VERSION_MAJOR < 3
parser->setEntityResolver (&resolver);
+#else
+ parser->getDomConfig()->setParameter(XMLUni::fgXercesEntityResolver, &resolver);
+#endif
//****************************************************************************************//
// End of air-gap code //
//****************************************************************************************//
@@ -189,7 +211,11 @@
///////////////////////////////////////////////////////
// Add an Error Handler
///////////////////////////////////////////////////////
+#if XERCES_VERSION_MAJOR < 3
parser->setErrorHandler(&errHandler);
+#else
+ parser->getDomConfig()->setParameter(XMLUni::fgDOMErrorHandler, &errHandler);
+#endif
// Fix a schema location if possible, so instance documents don't
// have to set the schemaLocation attribute. And if they do, this
@@ -197,7 +223,7 @@
// overriding of the value in instance documents.
if (!schemaLocation.empty()) {
XMLCh *schemaLocationCstr = XMLString::transcode(schemaLocation.c_str());
- parser->setProperty(XMLUni::fgXercesSchemaExternalSchemaLocation, schemaLocationCstr);
+ SetParameter(parser, XMLUni::fgXercesSchemaExternalSchemaLocation, schemaLocationCstr);
XMLString::release(&schemaLocationCstr);
}
@@ -279,23 +305,19 @@
XMLCh tempStr[100];
XMLString::transcode("LS", tempStr, 99);
DOMImplementation *impl = DOMImplementationRegistry::getDOMImplementation(tempStr);
+#if XERCES_VERSION_MAJOR < 3
DOMWriter *theSerializer = ((DOMImplementationLS*)impl)->createDOMWriter();
+#else
+ DOMLSSerializer *theSerializer = ((DOMImplementationLS*)impl)->createLSSerializer();
+#endif
- // set feature if the serializer supports the feature/mode
- if (theSerializer->canSetFeature(XMLUni::fgDOMWRTSplitCdataSections, true))
- theSerializer->setFeature(XMLUni::fgDOMWRTSplitCdataSections, true);
- if (theSerializer->canSetFeature(XMLUni::fgDOMWRTDiscardDefaultContent, true))
- theSerializer->setFeature(XMLUni::fgDOMWRTDiscardDefaultContent, true);
-
- if (theSerializer->canSetFeature(XMLUni::fgDOMWRTFormatPrettyPrint, true))
- theSerializer->setFeature(XMLUni::fgDOMWRTFormatPrettyPrint, true);
-
- if (theSerializer->canSetFeature(XMLUni::fgDOMWRTBOM, false))
- theSerializer->setFeature(XMLUni::fgDOMWRTBOM, false);
-
- //if (theSerializer->canSetFeature(XMLUni::fgDOMWRTDiscardDefaultContent, true))
- // theSerializer->setFeature(XMLUni::fgDOMWRTBOM, true);
+ // set feature if the serializer supports the feature/mode
+ SetParameter(theSerializer, XMLUni::fgDOMWRTSplitCdataSections, true);
+ SetParameter(theSerializer, XMLUni::fgDOMWRTDiscardDefaultContent, true);
+ SetParameter(theSerializer, XMLUni::fgDOMWRTFormatPrettyPrint, true);
+ SetParameter(theSerializer, XMLUni::fgDOMWRTBOM, false);
+ //SetParameter(theSerializer, XMLUni::fgDOMWRTBOM, true);
//
// Plug in a format target to receive the resultant
@@ -313,7 +335,13 @@
//
// do the serialization through DOMWriter::writeNode();
//
+#if XERCES_VERSION_MAJOR < 3
theSerializer->writeNode(myFormTarget, *doc);
+#else
+ DOMLSOutput *output = ((DOMImplementationLS*)impl)->createLSOutput();
+ output->setByteStream(myFormTarget);
+ theSerializer->write(doc, output);
+#endif
theSerializer->release();
delete myFormTarget;