aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ixslt.cc9
-rw-r--r--src/transformation_facade.cc45
-rw-r--r--src/transformation_facade.h60
-rw-r--r--test/default_params/reference.xml5
-rw-r--r--test/default_params/transformation.xsl23
-rw-r--r--test/read_directory/reference.xml3
6 files changed, 34 insertions, 111 deletions
diff --git a/ixslt.cc b/ixslt.cc
index b1671b3..abc7e1a 100644
--- a/ixslt.cc
+++ b/ixslt.cc
@@ -1,5 +1,6 @@
#include "boost/optional.hpp"
#include "boost/program_options.hpp"
+#include <boost/filesystem/fstream.hpp>
#include <string>
#include <vector>
@@ -117,9 +118,15 @@ bool process(const boost::program_options::variables_map& variables) {
try {
if ( variables.count("target") ) {
- transformation->generate(
+ boost::filesystem::ofstream file(
variables["target"].as<std::string>()
);
+
+ if ( file.is_open() ) {
+ transformation->generate(file);
+ } else {
+ return false;
+ }
} else {
transformation->generate(std::cout);
}
diff --git a/src/transformation_facade.cc b/src/transformation_facade.cc
index 97b17bb..9d248b8 100644
--- a/src/transformation_facade.cc
+++ b/src/transformation_facade.cc
@@ -3,10 +3,6 @@
#include <xalanc/XSLT/XSLTInputSource.hpp>
#include <xalanc/XalanTransformer/XalanCompiledStylesheet.hpp>
-#include "boost/filesystem.hpp"
-
-#include <sstream>
-
#include "support/xerces_string_guard.h"
namespace InputXSLT {
@@ -70,39 +66,34 @@ WarningCapacitor::warning_cache_ptr TransformationFacade::getCachedWarnings() {
return this->warning_capacitor_.discharge();
}
+void TransformationFacade::generate(std::basic_ostream<char>& targetStream) {
+ StylesheetParameterGuard guard(this->transformer_);
+
+ this->generate(targetStream, guard);
+}
+
void TransformationFacade::generate(
- const std::string& targetPath,
- StylesheetParameterGuard& parameters
+ std::basic_ostream<char>& targetStream,
+ const StylesheetParameterGuard::map& parameters
) {
- const boost::filesystem::path targetPathHelper(
- boost::filesystem::absolute(targetPath)
- );
-
- parameters.set(
- "target-file", targetPathHelper.filename().string()
- );
- parameters.set(
- "parent-directory", targetPathHelper.parent_path().filename().string()
- );
+ StylesheetParameterGuard guard(this->transformer_, parameters);
- this->generate(
- xalan::XSLTResultTarget(targetPath.data()),
- parameters
- );
+ this->generate(targetStream, guard);
}
void TransformationFacade::generate(
std::basic_ostream<char>& targetStream,
- StylesheetParameterGuard& parameters
+ const xalan::XObjectPtr& parameter
) {
- this->generate(
- xalan::XSLTResultTarget(targetStream),
- parameters
- );
+ StylesheetParameterGuard guard(this->transformer_);
+ guard.set("parameters", parameter);
+
+ this->generate(targetStream, guard);
}
+
void TransformationFacade::generate(
- xalan::XSLTResultTarget&& outputTarget,
+ std::basic_ostream<char>& targetStream,
StylesheetParameterGuard&
) {
ErrorCapacitor errorCapacitor(&this->error_multiplexer_);
@@ -110,7 +101,7 @@ void TransformationFacade::generate(
this->transformer_.transform(
*(this->input_),
this->transformation_,
- outputTarget
+ targetStream
);
errorCapacitor.discharge();
diff --git a/src/transformation_facade.h b/src/transformation_facade.h
index eb134cd..ca57de4 100644
--- a/src/transformation_facade.h
+++ b/src/transformation_facade.h
@@ -5,6 +5,7 @@
#include <string>
#include <memory>
+#include <sstream>
#include <functional>
#include "common.h"
@@ -26,9 +27,6 @@ class TransformationFacade {
Arguments&&...
);
- template<typename... Arguments>
- TransformationFacade(Arguments&&..., IncludeEntityResolver*);
-
TransformationFacade(
xalan::XSLTInputSource,
IncludeEntityResolver*
@@ -40,14 +38,9 @@ class TransformationFacade {
IncludeEntityResolver*
);
- template <typename Target>
- void generate(Target&);
-
- template <typename Target>
- void generate(Target&, const StylesheetParameterGuard::map&);
-
- template <typename Target>
- void generate(Target&, const xalan::XObjectPtr&);
+ void generate(std::basic_ostream<char>&);
+ void generate(std::basic_ostream<char>&, const StylesheetParameterGuard::map&);
+ void generate(std::basic_ostream<char>&, const xalan::XObjectPtr&);
WarningCapacitor::warning_cache_ptr getCachedWarnings();
@@ -59,9 +52,10 @@ class TransformationFacade {
ErrorMultiplexer error_multiplexer_;
WarningCapacitor warning_capacitor_;
- void generate(const std::string&, StylesheetParameterGuard&);
- void generate(std::basic_ostream<char>&, StylesheetParameterGuard&);
- void generate(xalan::XSLTResultTarget&&, StylesheetParameterGuard&);
+ void generate(
+ std::basic_ostream<char>&,
+ StylesheetParameterGuard&
+ );
};
@@ -84,44 +78,6 @@ auto TransformationFacade::try_create(
}
}
-template <typename... Arguments>
-TransformationFacade::TransformationFacade(
- Arguments&&... arguments,
- IncludeEntityResolver* resolver
-):
- TransformationFacade(
- xalan::XSLTInputSource(std::forward<Arguments>(arguments))...,
- resolver
- ) { }
-
-template <typename Target>
-void TransformationFacade::generate(Target& target) {
- StylesheetParameterGuard guard(this->transformer_);
-
- this->generate(target, guard);
-}
-
-template <typename Target>
-void TransformationFacade::generate(
- Target& target,
- const StylesheetParameterGuard::map& parameters
-) {
- StylesheetParameterGuard guard(this->transformer_, parameters);
-
- this->generate(target, guard);
-}
-
-template <typename Target>
-void TransformationFacade::generate(
- Target& target,
- const xalan::XObjectPtr& parameter
-) {
- StylesheetParameterGuard guard(this->transformer_);
- guard.set("parameters", parameter);
-
- this->generate(target, guard);
-}
-
}
#endif // INPUTXSLT_SRC_TRANSFORMATION_FACADE_H_
diff --git a/test/default_params/reference.xml b/test/default_params/reference.xml
deleted file mode 100644
index 566064b..0000000
--- a/test/default_params/reference.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<test_case>
-<target_file>actual.xml</target_file>
-<parent_directory>default_params</parent_directory>
-</test_case>
diff --git a/test/default_params/transformation.xsl b/test/default_params/transformation.xsl
deleted file mode 100644
index 54cf57e..0000000
--- a/test/default_params/transformation.xsl
+++ /dev/null
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<xsl:stylesheet
- version="1.0"
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- xmlns:InputXSLT="function.inputxslt.application"
- exclude-result-prefixes="InputXSLT"
->
-
-<xsl:import href="[testcase.xsl]"/>
-
-<xsl:param name="target-file"/>
-<xsl:param name="parent-directory"/>
-
-<xsl:template name="implementation">
- <target_file>
- <xsl:value-of select="$target-file"/>
- </target_file>
- <parent_directory>
- <xsl:value-of select="$parent-directory"/>
- </parent_directory>
-</xsl:template>
-
-</xsl:stylesheet>
diff --git a/test/read_directory/reference.xml b/test/read_directory/reference.xml
index b2eac35..7d63a85 100644
--- a/test/read_directory/reference.xml
+++ b/test/read_directory/reference.xml
@@ -11,9 +11,6 @@
<name>common</name>
</item>
<item type="directory">
-<name>default_params</name>
-</item>
-<item type="directory">
<name>external_text_formatter</name>
</item>
<item type="directory">