aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Kummerlaender2014-08-09 18:42:47 +0200
committerAdrian Kummerlaender2014-08-09 18:42:47 +0200
commit7f6611cded8c1591f1aa1a4c7d70505cb21e7967 (patch)
tree6be359d9f6b718c8ceea991f62fd12ef5c4c43c9
parent97b17caeeb8512e2af332d7095fca4cad160a980 (diff)
downloadInputXSLT-7f6611cded8c1591f1aa1a4c7d70505cb21e7967.tar
InputXSLT-7f6611cded8c1591f1aa1a4c7d70505cb21e7967.tar.gz
InputXSLT-7f6611cded8c1591f1aa1a4c7d70505cb21e7967.tar.bz2
InputXSLT-7f6611cded8c1591f1aa1a4c7d70505cb21e7967.tar.lz
InputXSLT-7f6611cded8c1591f1aa1a4c7d70505cb21e7967.tar.xz
InputXSLT-7f6611cded8c1591f1aa1a4c7d70505cb21e7967.tar.zst
InputXSLT-7f6611cded8c1591f1aa1a4c7d70505cb21e7967.zip
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
-rw-r--r--src/function/external_text_formatter.cc12
-rw-r--r--src/function/external_text_formatter.h4
-rw-r--r--src/function/generate.cc2
-rw-r--r--test/external_text_formatter/transformation.xsl2
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<std::string>{""},
+ 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 @@
<xsl:template name="implementation">
<xsl:variable name="result">
<xsl:call-template name="formatter">
- <xsl:with-param name="format">/usr/bin/markdown</xsl:with-param>
+ <xsl:with-param name="format">markdown</xsl:with-param>
<xsl:with-param name="file">[test.md]</xsl:with-param>
</xsl:call-template>
</xsl:variable>