diff options
author | Adrian Kummerländer | 2014-05-30 22:19:32 +0200 |
---|---|---|
committer | Adrian Kummerländer | 2014-05-30 22:19:32 +0200 |
commit | 79d3e2bdfd441d6eba2f22af78d5bea5e488daf1 (patch) | |
tree | b28b0603958140777ee46d98f2fc4359c9f72c4d /src/transformation_facade.cc | |
parent | 484143667bd6885236b679a8f54dad3c512ea2dd (diff) | |
download | InputXSLT-79d3e2bdfd441d6eba2f22af78d5bea5e488daf1.tar InputXSLT-79d3e2bdfd441d6eba2f22af78d5bea5e488daf1.tar.gz InputXSLT-79d3e2bdfd441d6eba2f22af78d5bea5e488daf1.tar.bz2 InputXSLT-79d3e2bdfd441d6eba2f22af78d5bea5e488daf1.tar.lz InputXSLT-79d3e2bdfd441d6eba2f22af78d5bea5e488daf1.tar.xz InputXSLT-79d3e2bdfd441d6eba2f22af78d5bea5e488daf1.tar.zst InputXSLT-79d3e2bdfd441d6eba2f22af78d5bea5e488daf1.zip |
Rewrote error handling based on exceptions
* ErrorHandler is replaced by ErrorCapacitor
** temporarily registers itself as both the ProblemListener and ErrorHandler of a given XalanTransformer instance
** deregisters itself on destruction
** collects all problems and errors during its lifetime inside a internal std::vector<std::string> instance
** if this instance is not empty it is thrown contained within a ErrorCapacitor::exception by the member method ErrorCapacitor::discharge
* this enables using the same code for handling transformation compilation and generation errors and problems
* updated test frontend accordingly
Diffstat (limited to 'src/transformation_facade.cc')
-rw-r--r-- | src/transformation_facade.cc | 49 |
1 files changed, 25 insertions, 24 deletions
diff --git a/src/transformation_facade.cc b/src/transformation_facade.cc index 8b9e1a2..f415cd8 100644 --- a/src/transformation_facade.cc +++ b/src/transformation_facade.cc @@ -14,16 +14,17 @@ TransformationFacade::TransformationFacade( IncludeEntityResolver* resolver ): transformation_{}, - transformer_(), - error_handler_() { + transformer_() { this->transformer_.setEntityResolver(resolver); - this->transformer_.setErrorHandler(&this->error_handler_); - this->transformer_.setProblemListener(&this->error_handler_); + + ErrorCapacitor errorCapacitor(&this->transformer_); this->transformer_.compileStylesheet( xalan::XSLTInputSource(transformation.data()), this->transformation_ ); + + errorCapacitor.discharge(); } TransformationFacade::~TransformationFacade() { @@ -32,10 +33,10 @@ TransformationFacade::~TransformationFacade() { ); } -auto TransformationFacade::generate( +void TransformationFacade::generate( const std::string& targetPath, StylesheetParameterGuard& parameters -) -> return_type { +) { const boost::filesystem::path targetPathHelper( boost::filesystem::absolute(targetPath) ); @@ -47,38 +48,38 @@ auto TransformationFacade::generate( "parent-directory", targetPathHelper.parent_path().filename().string() ); - return this->generate( + this->generate( xalan::XSLTResultTarget(targetPath.data()), parameters ); } -auto TransformationFacade::generate( +void TransformationFacade::generate( std::basic_ostream<char>& targetStream, StylesheetParameterGuard& parameters -) -> return_type { - return this->generate( +) { + this->generate( xalan::XSLTResultTarget(targetStream), parameters ); } -auto TransformationFacade::generate( +void TransformationFacade::generate( xalan::XSLTResultTarget&& outputTarget, StylesheetParameterGuard& -) -> return_type { - if ( this->transformation_ != nullptr ) { - std::stringstream emptyStream("<dummy/>"); - xalan::XSLTInputSource inputSource(emptyStream); - - this->transformer_.transform( - inputSource, - this->transformation_, - outputTarget - ); - } - - return this->error_handler_.getCachedErrors(); +) { + ErrorCapacitor errorCapacitor(&this->transformer_); + + std::stringstream emptyStream("<dummy/>"); + xalan::XSLTInputSource inputSource(emptyStream); + + this->transformer_.transform( + inputSource, + this->transformation_, + outputTarget + ); + + errorCapacitor.discharge(); } } |