aboutsummaryrefslogtreecommitdiff
path: root/src/transformation_facade.cc
diff options
context:
space:
mode:
authorAdrian Kummerländer2014-05-29 23:01:36 +0200
committerAdrian Kummerländer2014-05-29 23:01:36 +0200
commite402a092a5e2fbf624947896b013d405efb75049 (patch)
treefc43b178b39ff56669de5e9d3778019347e88d9a /src/transformation_facade.cc
parent3bc793d95293d40dbab62c593ce4ceaa86fae25b (diff)
downloadInputXSLT-e402a092a5e2fbf624947896b013d405efb75049.tar
InputXSLT-e402a092a5e2fbf624947896b013d405efb75049.tar.gz
InputXSLT-e402a092a5e2fbf624947896b013d405efb75049.tar.bz2
InputXSLT-e402a092a5e2fbf624947896b013d405efb75049.tar.lz
InputXSLT-e402a092a5e2fbf624947896b013d405efb75049.tar.xz
InputXSLT-e402a092a5e2fbf624947896b013d405efb75049.tar.zst
InputXSLT-e402a092a5e2fbf624947896b013d405efb75049.zip
Fixed error handling of invalid XSL transformations
* xalan is segfaulting in XalanDOMString constructor when the static member "XalanLocator::getSystemId" is returning null-pointer ** this should seemingly be handled by passing a pointer to the static constant m_dummy but this sadly fails to prevent the segfault ** the patch provided by this commit fixes the problem for now but I cannot guarantee that this wont cause any side effects in a other context * Adapted TransformationFacade to handle errors during transformation compilation ** errors generated during transformation compilation are returned through the generate member method ** throwing an exeception during TransformationFacade construction would require additional error handling in the calling code * Added xalan::ProblemListener functionality to the ErrorHandler class ** XSLT problems passed to the ProblemListener are returned alongside to and treated as all other transformation errors
Diffstat (limited to 'src/transformation_facade.cc')
-rw-r--r--src/transformation_facade.cc28
1 files changed, 10 insertions, 18 deletions
diff --git a/src/transformation_facade.cc b/src/transformation_facade.cc
index 0f174d8..8b9e1a2 100644
--- a/src/transformation_facade.cc
+++ b/src/transformation_facade.cc
@@ -18,6 +18,7 @@ TransformationFacade::TransformationFacade(
error_handler_() {
this->transformer_.setEntityResolver(resolver);
this->transformer_.setErrorHandler(&this->error_handler_);
+ this->transformer_.setProblemListener(&this->error_handler_);
this->transformer_.compileStylesheet(
xalan::XSLTInputSource(transformation.data()),
@@ -66,27 +67,18 @@ auto TransformationFacade::generate(
xalan::XSLTResultTarget&& outputTarget,
StylesheetParameterGuard&
) -> return_type {
- std::stringstream emptyStream("<dummy/>");
- xalan::XSLTInputSource inputSource(emptyStream);
-
- const int resultCode = this->transformer_.transform(
- inputSource,
- this->transformation_,
- outputTarget
- );
-
- return_type errors(this->error_handler_.getCachedErrors());
-
- if ( errors && resultCode != 0 ) {
- errors->emplace_back(
- "Transformation error with code " +
- std::to_string(resultCode) +
- ": " +
- this->transformer_.getLastError()
+ if ( this->transformation_ != nullptr ) {
+ std::stringstream emptyStream("<dummy/>");
+ xalan::XSLTInputSource inputSource(emptyStream);
+
+ this->transformer_.transform(
+ inputSource,
+ this->transformation_,
+ outputTarget
);
}
- return errors;
+ return this->error_handler_.getCachedErrors();
}
}