From 7f6611cded8c1591f1aa1a4c7d70505cb21e7967 Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Sat, 9 Aug 2014 18:42:47 +0200 Subject: Changed FunctionExternalTextFormatter to execute formatter inside shell * otherwise one has to pass the full path to the command ** additionally it is much easier to enable passing arguments to the external formatter this way * modified external function parameter accordingly * updated external text formatter test case --- src/function/external_text_formatter.cc | 12 ++++++------ src/function/external_text_formatter.h | 4 ++-- src/function/generate.cc | 2 -- test/external_text_formatter/transformation.xsl | 2 +- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/function/external_text_formatter.cc b/src/function/external_text_formatter.cc index 048f81a..03902e9 100644 --- a/src/function/external_text_formatter.cc +++ b/src/function/external_text_formatter.cc @@ -40,21 +40,21 @@ inline xercesc::DOMNode* importDocumentElement( namespace InputXSLT { DomDocumentCache::document_ptr FunctionExternalTextFormatter::constructDocument( - boost::filesystem::path formatterPath, - std::string stdinText + std::string formatterCommand, + std::string stdinText ) const { DomDocumentCache::document_ptr domDocument( DomDocumentCache::createDocument("content") ); boost::process::context context; + context.environment = boost::process::self::get_environment(); context.stdout_behavior = boost::process::capture_stream(); context.stdin_behavior = boost::process::capture_stream(); boost::process::child formatterProcess( - boost::process::launch( - formatterPath, - std::vector{""}, + boost::process::launch_shell( + formatterCommand, context ) ); @@ -68,7 +68,7 @@ DomDocumentCache::document_ptr FunctionExternalTextFormatter::constructDocument( boost::process::status status = formatterProcess.wait(); ResultNodeFacade result(domDocument.get(), "output"); - result.setAttribute("formatter", formatterPath.filename().string()); + result.setAttribute("formatter", formatterCommand); result.setAttribute("code", std::to_string(status.exit_status())); if ( status.exited() ) { diff --git a/src/function/external_text_formatter.h b/src/function/external_text_formatter.h index 27f2fc7..4788784 100644 --- a/src/function/external_text_formatter.h +++ b/src/function/external_text_formatter.h @@ -9,7 +9,7 @@ namespace InputXSLT { class FunctionExternalTextFormatter : public FunctionBase< FunctionExternalTextFormatter, - boost::filesystem::path, + std::string, std::string > { public: @@ -19,7 +19,7 @@ class FunctionExternalTextFormatter : public FunctionBase< friend FunctionBase; DomDocumentCache::document_ptr constructDocument( - boost::filesystem::path, + std::string, std::string ) const; diff --git a/src/function/generate.cc b/src/function/generate.cc index 0c5c664..df5e65b 100644 --- a/src/function/generate.cc +++ b/src/function/generate.cc @@ -37,8 +37,6 @@ DomDocumentCache::document_ptr FunctionGenerate::constructDocument( xalan::XalanOutputStreamPrintWriter writer(output); xalan::FormatterToXML targetFormatter(writer); - targetFormatter.setDoIndent(true); - transformer.generate( inputSource, transformationSource, diff --git a/test/external_text_formatter/transformation.xsl b/test/external_text_formatter/transformation.xsl index f797b87..aa9a300 100644 --- a/test/external_text_formatter/transformation.xsl +++ b/test/external_text_formatter/transformation.xsl @@ -25,7 +25,7 @@ - /usr/bin/markdown + markdown [test.md] -- cgit v1.2.3