From e805000b1841691cd58930e80bd896a4f7611fd0 Mon Sep 17 00:00:00 2001 From: Adrian Kummerländer Date: Tue, 10 Jun 2014 22:27:24 +0200 Subject: Added input file support to ixslt * a single file may be passed to the XSLT processor as input ** the file is read once and stored within a xalan::XalanParsedSource to be reused by all calls to "TransformationFacade::generate" * added appropriate TranformationFacade constructor overload ** this new constructor overload which is taking a path to both the transformation and the input file is the main constructor *** the old constructor is now only a alias for this new constructor * adapted static "try_create" TransformationFacade factory method into variadic template factory method * added optional "--input" argument to ixslt ** expanded option handling accordingly --- src/transformation_facade.h | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) (limited to 'src/transformation_facade.h') diff --git a/src/transformation_facade.h b/src/transformation_facade.h index f69786a..fe711bc 100644 --- a/src/transformation_facade.h +++ b/src/transformation_facade.h @@ -20,13 +20,19 @@ class TransformationFacade { public: typedef std::unique_ptr ptr; + template static ptr try_create( - const std::string&, - IncludeEntityResolver*, - const std::function& + const std::function&, + Arguments&&... ); TransformationFacade(const std::string&, IncludeEntityResolver*); + TransformationFacade( + const std::string&, + const std::string&, + IncludeEntityResolver* + ); + ~TransformationFacade(); template @@ -41,6 +47,7 @@ class TransformationFacade { WarningCapacitor::warning_cache_ptr getCachedWarnings(); private: + const xalan::XalanParsedSource* input_; const xalan::XalanCompiledStylesheet* transformation_; xalan::XalanTransformer transformer_; @@ -53,6 +60,25 @@ class TransformationFacade { }; +template +auto TransformationFacade::try_create( + const std::function& handleErrors, + Arguments&&... arguments +) -> ptr { + try { + return ptr( + new InputXSLT::TransformationFacade( + std::forward(arguments)... + ) + ); + } + catch (const ErrorCapacitor::exception& exception) { + handleErrors(*exception); + + return ptr(); + } +} + template void TransformationFacade::generate(Target& target) { StylesheetParameterGuard guard(this->transformer_); -- cgit v1.2.3