diff options
Diffstat (limited to 'src/function')
-rw-r--r-- | src/function/transform.cc | 72 | ||||
-rw-r--r-- | src/function/transform.h | 6 |
2 files changed, 35 insertions, 43 deletions
diff --git a/src/function/transform.cc b/src/function/transform.cc index 1d22399..e53b55f 100644 --- a/src/function/transform.cc +++ b/src/function/transform.cc @@ -6,7 +6,7 @@ #include <xercesc/dom/DOMImplementation.hpp> #include <xercesc/dom/DOMElement.hpp> -#include "transformation_facade.h" +#include "transformer_facade.h" #include "support/xerces_string_guard.h" #include "support/dom/result_node_facade.h" #include "support/error/error_capacitor.h" @@ -15,15 +15,15 @@ namespace { using InputXSLT::ErrorCapacitor; -inline std::function<void(const ErrorCapacitor::error_cache&)> handleErrors( - InputXSLT::ResultNodeFacade& result) { - return [&result](const ErrorCapacitor::error_cache& errors) { - result.setAttribute("result", "error"); +inline void handleErrors( + InputXSLT::ResultNodeFacade& result, + const ErrorCapacitor::error_cache& errors +) { + result.setAttribute("result", "error"); - for ( auto&& error : errors ) { - result.setValueNode("error", error); - } - }; + for ( auto&& error : errors ) { + result.setValueNode("error", error); + } } } @@ -32,8 +32,7 @@ namespace InputXSLT { xercesc::DOMDocument* FunctionTransform::constructDocument( xalan::XSLTInputSource inputSource, - xalan::XSLTInputSource transformationSource, - xalan::XObjectPtr parameterObject + xalan::XSLTInputSource transformationSource ) { xercesc::DOMDocument* const domDocument( xercesc::DOMImplementation::getImplementation()->createDocument( @@ -48,37 +47,32 @@ xercesc::DOMDocument* FunctionTransform::constructDocument( ); ResultNodeFacade result(domDocument, rootElement, "transformation"); + TransformerFacade transformer(this->include_resolver_); - if ( auto transformation = TransformationFacade::try_create( - handleErrors(result), - inputSource, - transformationSource, - this->include_resolver_ - ) ) { - try { - xalan::FormatterToXercesDOM formatter( - domDocument, - result.getResultElement() - ); - - transformation->generate( - formatter, - parameterObject - ); - - result.setAttribute("result", "success"); - } - catch (const ErrorCapacitor::exception& exception) { - handleErrors(result)(*exception); - } - - WarningCapacitor::warning_cache_ptr warnings( - transformation->getCachedWarnings() + try { + xalan::FormatterToXercesDOM targetFormatter( + domDocument, + result.getResultElement() ); - for ( auto&& warning : *warnings ) { - result.setValueNode("warning", warning); - } + transformer.generate( + inputSource, + transformationSource, + targetFormatter + ); + + result.setAttribute("result", "success"); + } + catch (const ErrorCapacitor::exception& exception) { + handleErrors(result, *exception); + } + + WarningCapacitor::warning_cache_ptr warnings( + transformer.getCachedWarnings() + ); + + for ( auto&& warning : *warnings ) { + result.setValueNode("warning", warning); } return domDocument; diff --git a/src/function/transform.h b/src/function/transform.h index 234a1d0..b8e733d 100644 --- a/src/function/transform.h +++ b/src/function/transform.h @@ -10,8 +10,7 @@ namespace InputXSLT { class FunctionTransform : public FunctionBase< FunctionTransform, xalan::XSLTInputSource, - xalan::XSLTInputSource, - xalan::XObjectPtr + xalan::XSLTInputSource > { public: using FunctionBase::FunctionBase; @@ -21,8 +20,7 @@ class FunctionTransform : public FunctionBase< xercesc::DOMDocument* constructDocument( xalan::XSLTInputSource, - xalan::XSLTInputSource, - xalan::XObjectPtr + xalan::XSLTInputSource ); }; |