-
Notifications
You must be signed in to change notification settings - Fork 59
/
Copy pathMSXMLWrapper.cpp
669 lines (592 loc) · 23.5 KB
/
MSXMLWrapper.cpp
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
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
#include "StdAfx.h"
#include "MSXMLWrapper.h"
#include "PluginInterface.h"
#include "Report.h"
#include <comutil.h>
MSXMLWrapper::MSXMLWrapper(const char* xml, size_t size) {
Report::char2BSTR(xml, size, this->m_sXml);
std::map<std::string, std::string> tristate{ { "-1", "default" }, { "0", "false" }, { "1", "true" } };
this->options["allowDocumentFunction"] = {
L"Allow document function",
L"",
L"-1",
OptionDataType::OPTION_TYPE_INTEGER,
OptionFormatType::OPTION_FORMAT_COMBO,
tristate
};
this->options["allowXsltScript"] = {
L"Allow Xslt Script",
L"",
L"-1",
OptionDataType::OPTION_TYPE_INTEGER,
OptionFormatType::OPTION_FORMAT_COMBO,
tristate
};
}
MSXMLWrapper::~MSXMLWrapper() {
this->resetErrors();
}
int MSXMLWrapper::getCapabilities() {
return XmlCapabilityType::ALL_OPTIONS;
}
void MSXMLWrapper::addErrorToVector(IXMLDOMParseError2* pXMLErr, const wchar_t* szDesc) {
HRESULT hr = S_OK;
long line = 0;
long linepos = 0;
long filepos = 0;
BSTR bstrReason = NULL;
ErrorEntryType err;
if (pXMLErr != NULL) {
CHK_HR(pXMLErr->get_reason(&bstrReason));
if (bstrReason != NULL) {
CHK_HR(pXMLErr->get_line(&line));
CHK_HR(pXMLErr->get_linepos(&linepos));
CHK_HR(pXMLErr->get_filepos(&filepos));
if (line == 0 || linepos == 0) {
line = 1;
linepos = 1;
}
if (line >= 0 && linepos >= 0 && filepos >= 0) {
err.positioned = TRUE;
err.line = (size_t) line;
err.linepos = (size_t)linepos;
err.filepos = (size_t)filepos + 1;
}
else {
err.positioned = FALSE;
err.line = 0;
err.linepos = 0;
err.filepos = 0;
}
err.reason = std::wstring((wchar_t*)bstr_t(bstrReason));
this->errors.push_back(err);
}
}
CleanUp:
SysFreeString(bstrReason);
}
void MSXMLWrapper::buildErrorsVector(IXMLDOMParseError2* pXMLErr, const wchar_t* szDesc) {
HRESULT hr = S_OK;
IXMLDOMParseErrorCollection* pAllErrors = NULL;
IXMLDOMParseError2* pTmpErr = NULL;
long length = 0;
this->resetErrors();
try {
CHK_HR(pXMLErr->get_allErrors(&pAllErrors));
if (pAllErrors != NULL) {
CHK_HR(pAllErrors->get_length(&length));
for (long i = 0; i < length; ++i) {
CHK_HR(pAllErrors->get_next(&pTmpErr));
CHK_HR(pAllErrors->get_item(i, &pTmpErr));
this->addErrorToVector(pTmpErr);
SAFE_RELEASE(pTmpErr);
}
SAFE_RELEASE(pAllErrors);
}
else {
this->addErrorToVector(pXMLErr, szDesc);
}
}
catch (...) {
this->addErrorToVector(pXMLErr, szDesc);
}
CleanUp:
SAFE_RELEASE(pAllErrors);
SAFE_RELEASE(pTmpErr);
}
bool MSXMLWrapper::checkSyntax() {
bool res = true;
//updateProxyConfig();
HRESULT hr = S_OK;
IXMLDOMDocument3* pXMLDom = NULL;
IXMLDOMParseError2* pXMLErr = NULL;
VARIANT_BOOL varStatus;
this->resetErrors();
CHK_HR(CreateAndInitDOM(&pXMLDom));
CHK_HR(pXMLDom->loadXML(this->m_sXml.m_str, &varStatus));
res = (varStatus == VARIANT_TRUE);
if (!res) {
CHK_HR(pXMLDom->get_parseError((IXMLDOMParseError**)&pXMLErr));
this->buildErrorsVector(pXMLErr);
}
CleanUp:
SAFE_RELEASE(pXMLDom);
SAFE_RELEASE(pXMLErr);
return res;
}
bool MSXMLWrapper::checkValidity(std::wstring schemaFilename, std::wstring validationNamespace) {
// source: https://docs.microsoft.com/en-us/previous-versions/windows/desktop/ms754649(v=vs.85)
HRESULT hr = S_OK;
IXMLDOMDocument3 *pXMLDom = NULL, // The MultipleErrorMessages property is supported by IXMLDOMDocument3, together with
*pXSDDom = NULL; // IXMLDOMParseError2 and IXMLDOMParseErrorCollection interfaces introduced in MSXML 5.0
IXMLDOMParseError2* pXMLErr = NULL;
IXMLDOMNodeList* pNodes = NULL;
IXMLDOMNode* pNode = NULL;
IXMLDOMElement* pElement = NULL;
IXMLDOMSchemaCollection2* pXS = NULL;
VARIANT_BOOL varStatus;
BSTR bstrNodeName = NULL;
bool res = true;
this->resetErrors();
CHK_HR(CreateAndInitDOM(&pXMLDom, (INIT_OPTION_VALIDATEONPARSE | INIT_OPTION_RESOLVEEXTERNALS)));
CHK_HR(pXMLDom->loadXML(this->m_sXml.m_str, &varStatus));
if (varStatus == VARIANT_TRUE) {
if (!schemaFilename.empty()) {
CHK_HR(CreateAndInitDOM(&pXSDDom, (INIT_OPTION_VALIDATEONPARSE | INIT_OPTION_RESOLVEEXTERNALS)));
CHK_HR(pXSDDom->load(CComVariant(schemaFilename.c_str()), &varStatus));
if (varStatus == VARIANT_TRUE) {
CHK_HR(CreateAndInitSchema(&pXS));
hr = pXS->add(_bstr_t(validationNamespace.c_str()), CComVariant(schemaFilename.c_str()));
if (SUCCEEDED(hr)) {
// Create a DOMDocument and set its properties.
SAFE_RELEASE(pXMLDom);
CHK_HR(CreateAndInitDOM(&pXMLDom, (INIT_OPTION_VALIDATEONPARSE | INIT_OPTION_RESOLVEEXTERNALS)));
CHK_HR(pXMLDom->putref_schemas(CComVariant(pXS)));
/*
pXMLDom->put_async(VARIANT_FALSE);
pXMLDom->put_validateOnParse(VARIANT_TRUE);
pXMLDom->put_resolveExternals(VARIANT_TRUE);
*/
CHK_HR(pXMLDom->loadXML(this->m_sXml.m_str, &varStatus));
if (varStatus != VARIANT_TRUE) {
CHK_HR(pXMLDom->get_parseError((IXMLDOMParseError**)&pXMLErr));
this->buildErrorsVector(pXMLErr);
res = false;
}
}
else {
this->errors.push_back({
FALSE,
0,
0,
0,
L"Invalid schema or missing namespace."
});
res = false;
}
}
else {
this->errors.push_back({
FALSE,
0,
0,
0,
L"The referenced schema is detected as being invalid. Please fix it before using it as validation schema."
});
res = false;
}
}
if (res) {
// If we are here, this means that noNamespaceSchemaLocation or schemaLocation attribute is present.
// So validation is supposed OK since xml is loaded with INIT_OPTION_VALIDATEONPARSE option. Then we
// just have to test validity.
if (pXMLDom->validate((IXMLDOMParseError**)&pXMLErr) == S_FALSE) {
this->buildErrorsVector(pXMLErr);
res = false;
}
}
}
else {
CHK_HR(pXMLDom->get_parseError((IXMLDOMParseError**)&pXMLErr));
this->buildErrorsVector(pXMLErr);
res = false;
}
CleanUp:
SAFE_RELEASE(pXMLDom);
SAFE_RELEASE(pXSDDom);
SAFE_RELEASE(pXMLErr);
SAFE_RELEASE(pNodes);
SAFE_RELEASE(pNode);
SAFE_RELEASE(pElement);
SAFE_RELEASE(pXS);
SysFreeString(bstrNodeName);
return res;
}
std::vector<XPathResultEntryType> MSXMLWrapper::xpathEvaluate(std::wstring xpath, std::wstring ns) {
HRESULT hr = S_OK;
IXMLDOMDocument3* pXMLDom = NULL;
IXMLDOMNodeList* pNodes = NULL;
IXMLDOMParseError2* pXMLErr = NULL;
VARIANT_BOOL varStatus;
IXMLDOMNode* pNode = NULL;
DOMNodeType nodeType;
BSTR bstrNodeName = NULL;
BSTR bstrNodeType = NULL;
CComBSTR bstrXPath;
VARIANT varNodeValue;
std::vector<XPathResultEntryType> res;
std::wstring value;
long length;
this->resetErrors();
UniMode encoding = Report::getEncoding(nppData._nppHandle);
Report::char2BSTR(xpath.c_str(), &bstrXPath);
CHK_ALLOC(bstrXPath);
CHK_HR(CreateAndInitDOM(&pXMLDom));
CHK_HR(pXMLDom->loadXML(this->m_sXml.m_str, &varStatus));
if (varStatus == VARIANT_TRUE) {
CHK_HR(pXMLDom->setProperty(L"SelectionNamespaces", _variant_t(ns.c_str())));
CHK_HR(pXMLDom->setProperty(L"SelectionLanguage", _variant_t(L"XPath")));
hr = pXMLDom->selectNodes(bstrXPath, &pNodes);
if (FAILED(hr)) {
CHK_HR(pXMLDom->get_parseError((IXMLDOMParseError**)&pXMLErr));
this->buildErrorsVector(pXMLErr);
this->errors.push_back({
FALSE,
0,
0,
0,
L"Error: error on XPath expression, or missing namespace definition."
});
goto CleanUp;
}
// create result
V_VT(&varNodeValue) = VT_UNKNOWN;
CHK_HR(pNodes->get_length(&length));
for (long i = 0; i < length; ++i) {
CHK_HR(pNodes->get_item(i, &pNode));
CHK_HR(pNode->get_nodeType(&nodeType));
CHK_HR(pNode->get_nodeName(&bstrNodeName));
CHK_HR(pNode->get_nodeValue(&varNodeValue));
CHK_HR(pNode->get_nodeTypeString(&bstrNodeType));
switch (nodeType) {
case NODE_ELEMENT: {
// let's concatenate all direct text children
// rem: pNode->get_text(&bstrNodeValue) is not appropriate
// because it concatenates the node content and the
// content of its descendants; in our case we only
// want direct child content
IXMLDOMNodeList* pNodeList;
// @fixme: would it be better to use CComPtr<IXMLDOMNodeList> pNodeList; ?
long numChildren;
value = L"";
CHK_HR(pNode->get_childNodes(&pNodeList));
CHK_HR(pNodeList->get_length(&numChildren));
for (long j = 0; j < numChildren; ++j) {
SAFE_RELEASE(pNode);
CHK_HR(pNodeList->get_item(j, &pNode));
CHK_HR(pNode->get_nodeType(&nodeType));
if (nodeType == NODE_TEXT) {
VariantClear(&varNodeValue);
CHK_HR(pNode->get_nodeValue(&varNodeValue));
if (varNodeValue.vt != VT_NULL) {
value += (wchar_t*)_bstr_t(varNodeValue);
}
}
SAFE_RELEASE(pNode);
}
SAFE_RELEASE(pNodeList);
break;
}
default: {
if (varNodeValue.vt != VT_NULL) {
value = (wchar_t*)_bstr_t(varNodeValue);
}
}
}
res.push_back({
bstrNodeType,
bstrNodeName,
value
});
SysFreeString(bstrNodeName);
SysFreeString(bstrNodeType);
VariantClear(&varNodeValue);
SAFE_RELEASE(pNode);
}
}
else {
CHK_HR(pXMLDom->get_parseError((IXMLDOMParseError**)&pXMLErr));
this->buildErrorsVector(pXMLErr);
}
CleanUp:
SAFE_RELEASE(pXMLDom);
SAFE_RELEASE(pNodes);
SAFE_RELEASE(pXMLErr);
bstrXPath.Empty();
SAFE_RELEASE(pNode);
SysFreeString(bstrNodeName);
SysFreeString(bstrNodeType);
return res;
}
/*
Get next key/val pair in string, starting from given position. The function
returns the position where parser stoped, or -1 (std::string::npos) when no
pair was found. The 'key' and 'val' variables are feeded with readen key and
value.
@todo: rewrite this method and use regex
*/
std::string::size_type getNextParam(std::wstring& str, std::string::size_type startpos, std::wstring* key, std::wstring* val) {
std::string::size_type len = str.length();
if (startpos == std::string::npos || startpos >= len || !key || !val) return std::string::npos;
// skip spaces, tabs and carriage returns
std::string::size_type keypos = str.find_first_not_of(L" \t\r\n", startpos);
if (keypos == std::string::npos || keypos >= len) return std::string::npos;
// next char shouldn't be a '='
if (str.at(keypos) == '=') return std::string::npos;
// keypos points on begin of the key; let's search for next '=' or ' '
std::string::size_type valpos = str.find_first_of(L"=", keypos + 1);
valpos = str.find_last_not_of(L" =", valpos); // get last char of the key
*key = str.substr(keypos, valpos - keypos + 1);
// skip the '='
valpos = 1 + str.find_first_of(L"=", valpos + 1);
if (str.at(valpos) == ' ') valpos = str.find_first_not_of(L" ", valpos); // skip eventual space chars
if (valpos < 0 || valpos >= len) return std::string::npos;
// here we must parse the string; if it starts with an apostroph, let's search
// the next apostroph; otherwise let's read the next word
std::string::size_type valendpos = valpos;
if (str.at(valendpos) == '\'') {
valendpos = str.find_first_of(L"\'", valendpos + 1);
*val = str.substr(valpos + 1, valendpos - valpos - 1); // get value without apostrophs
}
else {
valendpos = str.find_first_of(L" \t\r\n", valendpos);
// at the end of the string, valendpos = -1
if (valendpos == std::string::npos) valendpos = len;
*val = str.substr(valpos, valendpos - valpos);
}
return valendpos;
}
bool MSXMLWrapper::xslTransform(std::wstring xslfile, XSLTransformResultType* out, std::wstring options, UniMode srcEncoding) {
// inspired from https://www.codeguru.com/cpp/data/data-misc/xml/article.php/c4565/Doing-XSLT-with-MSXML-in-C.htm
// and msxsl tool source code (https://www.microsoft.com/en-us/download/details.aspx?id=21714)
HRESULT hr = S_OK;
HGLOBAL hg = NULL;
IXMLDOMDocument3* pXml = NULL;
IXMLDOMDocument3* pXslt = NULL;
IXSLTemplate* pTemplate = NULL;
IXSLProcessor* pProcessor = NULL;
IXMLDOMParseError2* pXMLErr = NULL;
IXMLDOMNodeList* pNodes = NULL;
IXMLDOMNode* pNode = NULL;
IStream* pOutStream = NULL;
VARIANT varValue;
VARIANT_BOOL varStatus;
BSTR bstrEncoding = NULL;
long length;
bool currentDataIsXml = true;
bool outputAsStream = false;
bool res = true;
this->resetErrors();
V_VT(&varValue) = VT_UNKNOWN;
// active document may either be XML or XSL; if XSL,
// then m_sSelectedFile refers to an XML file
CHK_HR(CreateAndInitDOM(&pXml));
CHK_HR(pXml->loadXML(this->m_sXml.m_str, &varStatus));
if (varStatus == VARIANT_TRUE) {
CHK_HR(pXml->setProperty(L"SelectionNamespaces", variant_t(L"xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\"")));
if (SUCCEEDED(pXml->selectNodes(L"/xsl:stylesheet", &pNodes))) {
CHK_HR(pNodes->get_length(&length));
if (length == 1) {
// the active document is an XSL one; let's invert both files
currentDataIsXml = false;
}
}
}
else {
CHK_HR(pXml->get_parseError((IXMLDOMParseError**)&pXMLErr));
this->buildErrorsVector(pXMLErr);
if (this->errors.size() == 0) {
this->errors.push_back({
FALSE,
0,
0,
0,
L"An error occurred during current source loading. Please check source validity. Transformation aborted."
});
}
res = false;
}
SAFE_RELEASE(pXml);
SAFE_RELEASE(pNodes);
if (!res) goto CleanUp;
// load xml
CHK_HR(CreateAndInitDOM(&pXml));
if (currentDataIsXml) {
CHK_HR(pXml->loadXML(this->m_sXml.m_str, &varStatus));
}
else {
CHK_HR(pXml->load(_variant_t(xslfile.c_str()), &varStatus));
}
if (varStatus == VARIANT_TRUE) {
// load xsl
CHK_HR(CreateAndInitDOM(&pXslt, (INIT_OPTION_PRESERVEWHITESPACE | INIT_OPTION_FREETHREADED)));
if (currentDataIsXml) {
CHK_HR(pXslt->load(_variant_t(xslfile.c_str()), &varStatus));
}
else {
CHK_HR(pXslt->loadXML(this->m_sXml.m_str, &varStatus));
}
if (varStatus == VARIANT_TRUE) {
// detect output encoding
CHK_HR(pXslt->setProperty(L"SelectionNamespaces", variant_t(L"xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\"")));
if (SUCCEEDED(pXslt->selectNodes(L"/xsl:stylesheet/xsl:output/@encoding", &pNodes))) {
CHK_HR(pNodes->get_length(&length));
if (length == 1) {
// get encoding from output declaration
pNodes->get_item(0, &pNode);
pNode->get_text(&bstrEncoding);
out->encoding = Report::getEncoding(bstrEncoding);
SAFE_RELEASE(pNode);
SAFE_RELEASE(pNodes);
/* disabled */ //outputAsStream = TRUE;
/*
* @fixme : outputAsStream might make the transformation processor crash.
* For instance, transforming
*
* <?xml version="1.0" encoding="ISO-8859-1"?>
* <a>‰</a>
*
* with following stylesheet:
*
* <?xml version="1.0" encoding="ISO-8859-1"?>
* <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
* <xsl:output method="text" encoding="ISO-8859-1"/>
*
* <xsl:template match="/">
* <xsl:value-of select="."/>
* </xsl:template>
* </xsl:stylesheet>
*
* fails because of xsl:output encoding.
*/
}
else {
// get encoding of source file
out->encoding = srcEncoding;
outputAsStream = FALSE;
}
}
CHK_HR(pXslt->setProperty(L"SelectionNamespaces", variant_t(L"")));
// build template
CHK_HR(CreateAndInitXSLTemplate(&pTemplate));
if (SUCCEEDED(pTemplate->putref_stylesheet(pXslt))) {
CHK_HR(pTemplate->createProcessor(&pProcessor));
// set startMode
// @todo
// set parameters; let's decode params string; the string should have the following form:
// variable1=value1;variable2=value2;variable3="value 3"
std::string::size_type i = std::string::npos;
std::wstring key, val;
while ((i = getNextParam(options, i + 1, &key, &val)) != std::string::npos) {
_bstr_t var0(key.c_str());
VARIANT var1;
VariantInit(&var1);
CHK_HR(VariantFromString(val.c_str(), var1));
CHK_HR(pProcessor->addParameter(var0, var1));
VariantClear(&var1);
}
// attach to processor XML file we want to transform,
// add one parameter, maxprice, with a value of 35, and
// do the transformation
CHK_HR(pProcessor->put_input(_variant_t(pXml)));
// method 1 -----------------------------------------------------------
if (outputAsStream) {
// prepare Stream object to store results of transformation,
// and set processor output to it
CHK_HR(CreateStreamOnHGlobal(0, TRUE, &pOutStream));
V_VT(&varValue) = VT_UNKNOWN;
V_UNKNOWN(&varValue) = (IUnknown*)pOutStream;
CHK_HR(pProcessor->put_output(varValue));
VariantClear(&varValue);
}
// transform
CHK_HR(pProcessor->transform(&varStatus));
if (varStatus == VARIANT_TRUE) {
// get results of transformation and send them to a new NPP document
if (outputAsStream) {
CHK_HR(pOutStream->Write((void const*)"\0", 1, 0));
CHK_HR(GetHGlobalFromStream(pOutStream, &hg));
char* tmp = (char*)GlobalLock(hg);
if (tmp != NULL) {
out->data = tmp;
}
else {
this->errors.push_back({
FALSE,
0,
0,
0,
L"An unexpected error occurred during XSL transformation"
});
res = false;
}
}
else {
pProcessor->get_output(&varValue);
if (out->encoding == UniMode::uniCookie || out->encoding == UniMode::uniUTF8) {
out->data = Report::BSTRtoUTF8(_bstr_t(varValue));
}
else {
out->data = _com_util::ConvertBSTRToString(_bstr_t(varValue));
}
VariantClear(&varValue);
}
if (outputAsStream) {
GlobalUnlock(hg);
}
}
else {
this->errors.push_back({
FALSE,
0,
0,
0,
L"An error occurred during XSL transformation"
});
res = false;
}
}
else {
this->errors.push_back({
FALSE,
0,
0,
0,
L"The XSL stylesheet is not valid. Transformation aborted."
});
res = false;
}
}
else {
CHK_HR(pXslt->get_parseError((IXMLDOMParseError**)&pXMLErr));
this->buildErrorsVector(pXMLErr);
res = false;
}
}
else {
CHK_HR(pXml->get_parseError((IXMLDOMParseError**)&pXMLErr));
this->buildErrorsVector(pXMLErr);
if (this->errors.size() == 0) {
if (currentDataIsXml) {
this->errors.push_back({
FALSE,
0,
0,
0,
L"An error occurred during XSL loading. Please check XSL validity. Transformation aborted."
});
}
else {
this->errors.push_back({
FALSE,
0,
0,
0,
L"An error occurred during XML loading. Please check XML validity. Transformation aborted."
});
}
}
res = false;
}
CleanUp:
SAFE_RELEASE(pXml);
SAFE_RELEASE(pXslt);
SAFE_RELEASE(pTemplate);
SAFE_RELEASE(pProcessor);
SAFE_RELEASE(pXMLErr);
SAFE_RELEASE(pOutStream);
SAFE_RELEASE(pNodes);
SAFE_RELEASE(pNode);
SysFreeString(bstrEncoding);
return res;
}