aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAdrian Kummerländer2014-05-01 18:14:33 +0200
committerAdrian Kummerländer2014-05-01 18:14:33 +0200
commite9c4e2b716798002c9ccbf96ee509eb91ad56553 (patch)
tree6032d0bac105a0c015a9042fb858dc853893a8a9 /src
parent29a6c1ab8b82491bcd54ad027e45644fde09ef59 (diff)
downloadInputXSLT-e9c4e2b716798002c9ccbf96ee509eb91ad56553.tar
InputXSLT-e9c4e2b716798002c9ccbf96ee509eb91ad56553.tar.gz
InputXSLT-e9c4e2b716798002c9ccbf96ee509eb91ad56553.tar.bz2
InputXSLT-e9c4e2b716798002c9ccbf96ee509eb91ad56553.tar.lz
InputXSLT-e9c4e2b716798002c9ccbf96ee509eb91ad56553.tar.xz
InputXSLT-e9c4e2b716798002c9ccbf96ee509eb91ad56553.tar.zst
InputXSLT-e9c4e2b716798002c9ccbf96ee509eb91ad56553.zip
Added basic parameter taking overload of TransformationFacade::generate
* XSLT stylesheets may be provided with a set of initial parameters ** these parameters can be provided as the second argument to the generate member method in the form of a string to string mapping ** the XSLT standard also permitts number and node set types as value arguments of such input parameters but this is not supported by this change * expanded test transformation to demonstrate this feature
Diffstat (limited to 'src')
-rw-r--r--src/transformation_facade.cc19
-rw-r--r--src/transformation_facade.h4
2 files changed, 23 insertions, 0 deletions
diff --git a/src/transformation_facade.cc b/src/transformation_facade.cc
index 846c586..3fee24f 100644
--- a/src/transformation_facade.cc
+++ b/src/transformation_facade.cc
@@ -55,6 +55,7 @@ int TransformationFacade::generate(const std::string& target) {
xalan::XSLTInputSource inputSource(emptyStream);
xalan::XSLTResultTarget outputTarget(target.data());
+
const int resultCode = this->transformer_.transform(
inputSource,
this->transformation_,
@@ -68,4 +69,22 @@ int TransformationFacade::generate(const std::string& target) {
return resultCode;
}
+int TransformationFacade::generate(
+ const std::string& target,
+ const parameter_map& parameters
+) {
+ for ( auto&& parameter : parameters ) {
+ this->transformer_.setStylesheetParam(
+ parameter.first.data(),
+ parameter.second.data()
+ );
+ }
+
+ const int resultCode = this->generate(target);
+
+ this->transformer_.clearStylesheetParams();
+
+ return resultCode;
+}
+
}
diff --git a/src/transformation_facade.h b/src/transformation_facade.h
index 765a376..880335f 100644
--- a/src/transformation_facade.h
+++ b/src/transformation_facade.h
@@ -4,6 +4,7 @@
#include <xalanc/XalanTransformer/XalanTransformer.hpp>
#include <string>
+#include <unordered_map>
#include "common.h"
#include "support/filesystem_context.h"
@@ -12,10 +13,13 @@ namespace InputXSLT {
class TransformationFacade {
public:
+ typedef std::unordered_map<std::string, std::string> parameter_map;
+
TransformationFacade(const std::string&);
~TransformationFacade();
int generate(const std::string&);
+ int generate(const std::string&, const parameter_map&);
private:
const FilesystemContext fs_context_;