aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Kummerlaender2014-07-05 21:55:48 +0200
committerAdrian Kummerlaender2014-07-05 21:55:48 +0200
commita02dce3c8e6086acbfe9c57c3ee4bb386bfbebc2 (patch)
tree669ad392772fcc9ab4eaa9e1a410156d6d4cc616
parentf05e742b88e3ebf7401c252332022f1a2f7eb8b0 (diff)
downloadInputXSLT-a02dce3c8e6086acbfe9c57c3ee4bb386bfbebc2.tar
InputXSLT-a02dce3c8e6086acbfe9c57c3ee4bb386bfbebc2.tar.gz
InputXSLT-a02dce3c8e6086acbfe9c57c3ee4bb386bfbebc2.tar.bz2
InputXSLT-a02dce3c8e6086acbfe9c57c3ee4bb386bfbebc2.tar.lz
InputXSLT-a02dce3c8e6086acbfe9c57c3ee4bb386bfbebc2.tar.xz
InputXSLT-a02dce3c8e6086acbfe9c57c3ee4bb386bfbebc2.tar.zst
InputXSLT-a02dce3c8e6086acbfe9c57c3ee4bb386bfbebc2.zip
Revamped implementation to support FunctionTransform XalanNode input
* FunctionTransform now accepts xalan::XalanNode base xalan::XSLTInputSource instances as input parameter ** such xalan::XSLTInputSource instances were already supported for the stylesheet parameter but not for the input parameter ** e.g. it is now possible to generate a DOM inside a transformation, pass the DOM into a embedded transformation as input, modifiy the output of that transformation, pass this modified DOM into another transformation and so on... you get the point * this required a revamp of TransformationFacade ** it is now a transformation independent wrapper for xalan::XalanTransformer *** as such is was renamed to TransformerFacade ** removed error catching template factory method "try_create" as it is not needed anymore ** "std::basic_ostream<char>&" taking "generate" member method overloads were removed ** the set of "generate" member overloads was reduced to two methods accepting xalan::XSLTInputSource and xalan::FormatterListener as parameters * the core problem first documented in 299d0f6 was solved by transforming the input parameter into a xerces DOM and wrapping this DOM inside a xalan::XercesDOMWrapperParsedSource instance * serialization of the transformation result for file / std::cout output is now performed directly by the ixslt frontend * removed 'stylesheet parameter' parameter from FunctionTransform ** the functionality provided by this is easily replicated using the now possible DOM input parameter ** this was done to simplify the interface and reduce unnecessary feature duplication * updated FunctionTransform test case accordingly * added "generate" template function to ixslt frontend ** wraps TransformerFacade and manages ist input arguments ** handles serialization to stream * this commit marks a important milestone towards the goals defined in 741a70f
-rw-r--r--CMakeLists.txt3
-rw-r--r--ixslt.cc115
-rw-r--r--src/function/transform.cc72
-rw-r--r--src/function/transform.h6
-rw-r--r--src/support/stylesheet_parameter_guard.cc46
-rw-r--r--src/support/stylesheet_parameter_guard.h37
-rw-r--r--src/transformation_facade.cc116
-rw-r--r--src/transformation_facade.h80
-rw-r--r--src/transformer_facade.cc129
-rw-r--r--src/transformer_facade.h46
-rw-r--r--test/transform/reference.xml4
-rw-r--r--test/transform/test.xsl10
-rw-r--r--test/transform/transformation.xsl25
13 files changed, 306 insertions, 383 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 73e67b0..9533c63 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -23,14 +23,13 @@ set(
set(
Sources
src/plattform_guard.cc
- src/transformation_facade.cc
+ src/transformer_facade.cc
src/function/read_file.cc
src/function/write_file.cc
src/function/read_directory.cc
src/function/transform.cc
src/function/external_text_formatter.cc
src/support/filesystem_context.cc
- src/support/stylesheet_parameter_guard.cc
src/support/xalan_string.cc
src/support/include_entity_resolver.cc
src/support/error/error_multiplexer.cc
diff --git a/ixslt.cc b/ixslt.cc
index abc7e1a..048f990 100644
--- a/ixslt.cc
+++ b/ixslt.cc
@@ -1,3 +1,7 @@
+#include <xalanc/PlatformSupport/XalanOutputStreamPrintWriter.hpp>
+#include <xalanc/PlatformSupport/XalanStdOutputStream.hpp>
+#include <xalanc/XMLSupport/FormatterToXML.hpp>
+
#include "boost/optional.hpp"
#include "boost/program_options.hpp"
#include <boost/filesystem/fstream.hpp>
@@ -7,16 +11,18 @@
#include <iostream>
#include "plattform_guard.h"
-#include "transformation_facade.h"
+#include "transformer_facade.h"
+
+namespace {
class WarningGuard {
public:
- WarningGuard(InputXSLT::TransformationFacade* transformation):
- transformation_(transformation) { };
+ WarningGuard(InputXSLT::TransformerFacade* transformer):
+ transformer_(transformer) { };
~WarningGuard() {
InputXSLT::WarningCapacitor::warning_cache_ptr warnings(
- this->transformation_->getCachedWarnings()
+ this->transformer_->getCachedWarnings()
);
for ( auto&& warning : *warnings ) {
@@ -25,7 +31,7 @@ class WarningGuard {
};
private:
- InputXSLT::TransformationFacade* const transformation_;
+ InputXSLT::TransformerFacade* const transformer_;
};
@@ -88,6 +94,36 @@ void handleErrors(const InputXSLT::ErrorCapacitor::error_cache& errors) {
}
}
+template <typename... Arguments>
+bool generate(
+ InputXSLT::IncludeEntityResolver* resolver,
+ std::basic_ostream<char>& target,
+ Arguments&&... arguments
+) {
+ InputXSLT::TransformerFacade transformer(resolver);
+ WarningGuard guard(&transformer);
+
+ try {
+ xalan::XalanStdOutputStream output(target);
+ xalan::XalanOutputStreamPrintWriter writer(output);
+ xalan::FormatterToXML formatter(writer);
+
+ formatter.setDoIndent(true);
+
+ transformer.generate(
+ std::forward<Arguments>(arguments)...,
+ formatter
+ );
+
+ return true;
+ }
+ catch (const InputXSLT::ErrorCapacitor::exception& exception) {
+ handleErrors(*exception);
+
+ return false;
+ }
+}
+
bool process(const boost::program_options::variables_map& variables) {
std::vector<std::string> includePath;
@@ -96,51 +132,48 @@ bool process(const boost::program_options::variables_map& variables) {
};
InputXSLT::PlattformGuard plattform(includePath);
- InputXSLT::TransformationFacade::ptr transformation{};
-
- if ( variables.count("input") ) {
- transformation = InputXSLT::TransformationFacade::try_create(
- handleErrors,
- variables["input"].as<std::string>().data(),
- variables["transformation"].as<std::string>().data(),
- plattform.getEntityResolver()
- );
- } else {
- transformation = InputXSLT::TransformationFacade::try_create(
- handleErrors,
- variables["transformation"].as<std::string>().data(),
- plattform.getEntityResolver()
- );
- }
- if ( transformation ) {
- WarningGuard guard(transformation.get());
+ if ( variables.count("target") ) {
+ boost::filesystem::ofstream file(
+ variables["target"].as<std::string>()
+ );
- try {
- if ( variables.count("target") ) {
- boost::filesystem::ofstream file(
- variables["target"].as<std::string>()
+ if ( file.is_open() ) {
+ if ( variables.count("input") ) {
+ return generate(
+ plattform.getEntityResolver(),
+ file,
+ variables["input"].as<std::string>().data(),
+ variables["transformation"].as<std::string>().data()
);
-
- if ( file.is_open() ) {
- transformation->generate(file);
- } else {
- return false;
- }
} else {
- transformation->generate(std::cout);
+ return generate(
+ plattform.getEntityResolver(),
+ file,
+ variables["transformation"].as<std::string>().data()
+ );
}
-
- return true;
- }
- catch (const InputXSLT::ErrorCapacitor::exception& exception) {
- handleErrors(*exception);
-
+ } else {
return false;
}
+ } else {
+ if ( variables.count("input") ) {
+ return generate(
+ plattform.getEntityResolver(),
+ std::cout,
+ variables["input"].as<std::string>().data(),
+ variables["transformation"].as<std::string>().data()
+ );
+ } else {
+ return generate(
+ plattform.getEntityResolver(),
+ std::cout,
+ variables["transformation"].as<std::string>().data()
+ );
+ }
}
+}
- return false;
}
int main(int argc, char** argv) {
diff --git a/src/function/transform.cc b/src/function/transform.cc
index 1d22399..e53b55f 100644
--- a/src/function/transform.cc
+++ b/src/function/transform.cc
@@ -6,7 +6,7 @@
#include <xercesc/dom/DOMImplementation.hpp>
#include <xercesc/dom/DOMElement.hpp>
-#include "transformation_facade.h"
+#include "transformer_facade.h"
#include "support/xerces_string_guard.h"
#include "support/dom/result_node_facade.h"
#include "support/error/error_capacitor.h"
@@ -15,15 +15,15 @@ namespace {
using InputXSLT::ErrorCapacitor;
-inline std::function<void(const ErrorCapacitor::error_cache&)> handleErrors(
- InputXSLT::ResultNodeFacade& result) {
- return [&result](const ErrorCapacitor::error_cache& errors) {
- result.setAttribute("result", "error");
+inline void handleErrors(
+ InputXSLT::ResultNodeFacade& result,
+ const ErrorCapacitor::error_cache& errors
+) {
+ result.setAttribute("result", "error");
- for ( auto&& error : errors ) {
- result.setValueNode("error", error);
- }
- };
+ for ( auto&& error : errors ) {
+ result.setValueNode("error", error);
+ }
}
}
@@ -32,8 +32,7 @@ namespace InputXSLT {
xercesc::DOMDocument* FunctionTransform::constructDocument(
xalan::XSLTInputSource inputSource,
- xalan::XSLTInputSource transformationSource,
- xalan::XObjectPtr parameterObject
+ xalan::XSLTInputSource transformationSource
) {
xercesc::DOMDocument* const domDocument(
xercesc::DOMImplementation::getImplementation()->createDocument(
@@ -48,37 +47,32 @@ xercesc::DOMDocument* FunctionTransform::constructDocument(
);
ResultNodeFacade result(domDocument, rootElement, "transformation");
+ TransformerFacade transformer(this->include_resolver_);
- if ( auto transformation = TransformationFacade::try_create(
- handleErrors(result),
- inputSource,
- transformationSource,
- this->include_resolver_
- ) ) {
- try {
- xalan::FormatterToXercesDOM formatter(
- domDocument,
- result.getResultElement()
- );
-
- transformation->generate(
- formatter,
- parameterObject
- );
-
- result.setAttribute("result", "success");
- }
- catch (const ErrorCapacitor::exception& exception) {
- handleErrors(result)(*exception);
- }
-
- WarningCapacitor::warning_cache_ptr warnings(
- transformation->getCachedWarnings()
+ try {
+ xalan::FormatterToXercesDOM targetFormatter(
+ domDocument,
+ result.getResultElement()
);
- for ( auto&& warning : *warnings ) {
- result.setValueNode("warning", warning);
- }
+ transformer.generate(
+ inputSource,
+ transformationSource,
+ targetFormatter
+ );
+
+ result.setAttribute("result", "success");
+ }
+ catch (const ErrorCapacitor::exception& exception) {
+ handleErrors(result, *exception);
+ }
+
+ WarningCapacitor::warning_cache_ptr warnings(
+ transformer.getCachedWarnings()
+ );
+
+ for ( auto&& warning : *warnings ) {
+ result.setValueNode("warning", warning);
}
return domDocument;
diff --git a/src/function/transform.h b/src/function/transform.h
index 234a1d0..b8e733d 100644
--- a/src/function/transform.h
+++ b/src/function/transform.h
@@ -10,8 +10,7 @@ namespace InputXSLT {
class FunctionTransform : public FunctionBase<
FunctionTransform,
xalan::XSLTInputSource,
- xalan::XSLTInputSource,
- xalan::XObjectPtr
+ xalan::XSLTInputSource
> {
public:
using FunctionBase::FunctionBase;
@@ -21,8 +20,7 @@ class FunctionTransform : public FunctionBase<
xercesc::DOMDocument* constructDocument(
xalan::XSLTInputSource,
- xalan::XSLTInputSource,
- xalan::XObjectPtr
+ xalan::XSLTInputSource
);
};
diff --git a/src/support/stylesheet_parameter_guard.cc b/src/support/stylesheet_parameter_guard.cc
deleted file mode 100644
index 399bccb..0000000
--- a/src/support/stylesheet_parameter_guard.cc
+++ /dev/null
@@ -1,46 +0,0 @@
-#include "stylesheet_parameter_guard.h"
-
-namespace InputXSLT {
-
-StylesheetParameterGuard::StylesheetParameterGuard(
- xalan::XalanTransformer& transformer
-): transformer_(transformer) { }
-
-StylesheetParameterGuard::StylesheetParameterGuard(
- xalan::XalanTransformer& transformer,
- const map& parameters
-): transformer_(transformer) {
- this->set(parameters);
-}
-
-StylesheetParameterGuard::~StylesheetParameterGuard() {
- this->transformer_.clearStylesheetParams();
-}
-
-void StylesheetParameterGuard::set(const map& parameters) {
- for ( auto&& parameter : parameters ) {
- this->set(parameter.first, parameter.second);
- }
-}
-
-void StylesheetParameterGuard::set(
- const std::string& key,
- const std::string& value
-) {
- this->transformer_.setStylesheetParam(
- key.data(),
- std::string("'" + value + "'").data()
- );
-}
-
-void StylesheetParameterGuard::set(
- const std::string& key,
- const xalan::XObjectPtr& value
-) {
- this->transformer_.setStylesheetParam(
- key.data(),
- value
- );
-}
-
-}
diff --git a/src/support/stylesheet_parameter_guard.h b/src/support/stylesheet_parameter_guard.h
deleted file mode 100644
index 7fa425e..0000000
--- a/src/support/stylesheet_parameter_guard.h
+++ /dev/null
@@ -1,37 +0,0 @@
-#ifndef INPUTXSLT_SRC_SUPPORT_STYLESHEET_PARAMETER_GUARD_H_
-#define INPUTXSLT_SRC_SUPPORT_STYLESHEET_PARAMETER_GUARD_H_
-
-#include <xalanc/XalanTransformer/XalanTransformer.hpp>
-#include <xalanc/XPath/XObject.hpp>
-
-#include <string>
-#include <unordered_map>
-
-#include "common.h"
-
-namespace InputXSLT {
-
-class StylesheetParameterGuard {
- public:
- typedef std::unordered_map<std::string, std::string> map;
-
- explicit StylesheetParameterGuard(xalan::XalanTransformer&);
- StylesheetParameterGuard(
- xalan::XalanTransformer&,
- const map&
- );
-
- ~StylesheetParameterGuard();
-
- void set(const map&);
- void set(const std::string&, const std::string&);
- void set(const std::string&, const xalan::XObjectPtr&);
-
- private:
- xalan::XalanTransformer& transformer_;
-
-};
-
-}
-
-#endif // INPUTXSLT_SRC_SUPPORT_STYLESHEET_PARAMETER_GUARD_H_
diff --git a/src/transformation_facade.cc b/src/transformation_facade.cc
deleted file mode 100644
index 4017cd0..0000000
--- a/src/transformation_facade.cc
+++ /dev/null
@@ -1,116 +0,0 @@
-#include "transformation_facade.h"
-
-#include <xalanc/XSLT/XSLTInputSource.hpp>
-#include <xalanc/XalanTransformer/XalanCompiledStylesheet.hpp>
-#include <xalanc/PlatformSupport/XalanOutputStreamPrintWriter.hpp>
-#include <xalanc/PlatformSupport/XalanStdOutputStream.hpp>
-#include <xalanc/XMLSupport/FormatterToXML.hpp>
-
-#include "support/xerces_string_guard.h"
-
-namespace InputXSLT {
-
-TransformationFacade::TransformationFacade(
- xalan::XSLTInputSource transformation,
- IncludeEntityResolver* resolver
-):
- input_{},
- transformation_{},
- transformer_(),
- error_multiplexer_(&transformer_),
- warning_capacitor_(&error_multiplexer_) {
- this->transformer_.setEntityResolver(resolver);
-
- ErrorCapacitor errorCapacitor(&this->error_multiplexer_);
-
- std::stringstream dummyStream("<dummy/>");
-
- this->transformer_.parseSource(
- xalan::XSLTInputSource(dummyStream),
- this->input_
- );
-
- this->transformer_.compileStylesheet(
- transformation,
- this->transformation_
- );
-
- errorCapacitor.discharge();
-}
-
-TransformationFacade::TransformationFacade(
- xalan::XSLTInputSource input,
- xalan::XSLTInputSource transformation,
- IncludeEntityResolver* resolver
-):
- input_{},
- transformation_{},
- transformer_(),
- error_multiplexer_(&transformer_),
- warning_capacitor_(&error_multiplexer_) {
- this->transformer_.setEntityResolver(resolver);
-
- ErrorCapacitor errorCapacitor(&this->error_multiplexer_);
-
- this->transformer_.parseSource(
- input,
- this->input_
- );
-
- this->transformer_.compileStylesheet(
- transformation,
- this->transformation_
- );
-
- errorCapacitor.discharge();
-}
-
-WarningCapacitor::warning_cache_ptr TransformationFacade::getCachedWarnings() {
- return this->warning_capacitor_.discharge();
-}
-
-void TransformationFacade::generate(
- std::basic_ostream<char>& targetStream,
- const xalan::XObjectPtr& parameter
-) {
- StylesheetParameterGuard guard(this->transformer_);
- guard.set("parameters", parameter);
-
- this->generate(targetStream);
-}
-
-void TransformationFacade::generate(std::basic_ostream<char>& targetStream) {
- StylesheetParameterGuard guard(this->transformer_);
-
- xalan::XalanStdOutputStream outputStream(targetStream);
- xalan::XalanOutputStreamPrintWriter outputWriter(outputStream);
-
- xalan::FormatterToXML formatter(outputWriter);
- formatter.setDoIndent(true);
-
- this->generate(formatter);
-}
-
-void TransformationFacade::generate(
- xalan::FormatterListener& formatter,
- const xalan::XObjectPtr& parameter
-) {
- StylesheetParameterGuard guard(this->transformer_);
- guard.set("parameters", parameter);
-
- this->generate(formatter);
-}
-
-void TransformationFacade::generate(xalan::FormatterListener& target) {
- ErrorCapacitor errorCapacitor(&this->error_multiplexer_);
-
- this->transformer_.transform(
- *(this->input_),
- this->transformation_,
- target
- );
-
- errorCapacitor.discharge();
-}
-
-}
diff --git a/src/transformation_facade.h b/src/transformation_facade.h
deleted file mode 100644
index e4cbc10..0000000
--- a/src/transformation_facade.h
+++ /dev/null
@@ -1,80 +0,0 @@
-#ifndef INPUTXSLT_SRC_TRANSFORMATION_FACADE_H_
-#define INPUTXSLT_SRC_TRANSFORMATION_FACADE_H_
-
-#include <xalanc/XalanTransformer/XalanTransformer.hpp>
-
-#include <string>
-#include <memory>
-#include <sstream>
-#include <functional>
-
-#include "common.h"
-#include "support/include_entity_resolver.h"
-#include "support/stylesheet_parameter_guard.h"
-#include "support/error/error_multiplexer.h"
-#include "support/error/error_capacitor.h"
-#include "support/error/warning_capacitor.h"
-
-namespace InputXSLT {
-
-class TransformationFacade {
- public:
- typedef std::unique_ptr<TransformationFacade> ptr;
-
- template <typename... Arguments>
- static ptr try_create(
- const std::function<void(const ErrorCapacitor::error_cache&)>&,
- Arguments&&...
- );
-
- TransformationFacade(
- xalan::XSLTInputSource,
- IncludeEntityResolver*
- );
-
- TransformationFacade(
- xalan::XSLTInputSource,
- xalan::XSLTInputSource,
- IncludeEntityResolver*
- );
-
- void generate(std::basic_ostream<char>&);
- void generate(std::basic_ostream<char>&, const xalan::XObjectPtr&);
-
- void generate(xalan::FormatterListener&);
- void generate(xalan::FormatterListener&, const xalan::XObjectPtr&);
-
- WarningCapacitor::warning_cache_ptr getCachedWarnings();
-
- private:
- const xalan::XalanParsedSource* input_;
- const xalan::XalanCompiledStylesheet* transformation_;
-
- xalan::XalanTransformer transformer_;
- ErrorMultiplexer error_multiplexer_;
- WarningCapacitor warning_capacitor_;
-
-};
-
-template <typename... Arguments>
-auto TransformationFacade::try_create(
- const std::function<void(const ErrorCapacitor::error_cache&)>& handleErrors,
- Arguments&&... arguments
-) -> ptr {
- try {
- return ptr(
- new InputXSLT::TransformationFacade(
- std::forward<Arguments>(arguments)...
- )
- );
- }
- catch (const ErrorCapacitor::exception& exception) {
- handleErrors(*exception);
-
- return ptr();
- }
-}
-
-}
-
-#endif // INPUTXSLT_SRC_TRANSFORMATION_FACADE_H_
diff --git a/src/transformer_facade.cc b/src/transformer_facade.cc
new file mode 100644
index 0000000..10c8c7a
--- /dev/null
+++ b/src/transformer_facade.cc
@@ -0,0 +1,129 @@
+#include "transformer_facade.h"
+
+#include <xalanc/PlatformSupport/XalanOutputStreamPrintWriter.hpp>
+#include <xalanc/PlatformSupport/XalanStdOutputStream.hpp>
+
+#include <xalanc/XMLSupport/FormatterToXML.hpp>
+#include <xalanc/XercesParserLiaison/FormatterToXercesDOM.hpp>
+#include <xalanc/XMLSupport/FormatterTreeWalker.hpp>
+
+#include <xalanc/XercesParserLiaison/XercesParserLiaison.hpp>
+#include <xalanc/XercesParserLiaison/XercesDOMSupport.hpp>
+#include <xalanc/XalanTransformer/XercesDOMWrapperParsedSource.hpp>
+
+#include <xercesc/dom/DOMDocument.hpp>
+#include <xercesc/dom/DOMImplementation.hpp>
+
+#include "support/xerces_string_guard.h"
+
+namespace InputXSLT {
+
+TransformerFacade::TransformerFacade(IncludeEntityResolver* resolver):
+ transformer_(),
+ error_multiplexer_(&transformer_),
+ warning_capacitor_(&error_multiplexer_) {
+ this->transformer_.setEntityResolver(resolver);
+}
+
+WarningCapacitor::warning_cache_ptr TransformerFacade::getCachedWarnings() {
+ return this->warning_capacitor_.discharge();
+}
+
+void TransformerFacade::generate(
+ const xalan::XSLTInputSource& source,
+ const xalan::XSLTInputSource& transformation,
+ xalan::FormatterListener& target
+) {
+ if ( source.getNode() == nullptr ) {
+ ErrorCapacitor errorCapacitor(&this->error_multiplexer_);
+
+ this->transformer_.transform(
+ source,
+ transformation,
+ target
+ );
+
+ errorCapacitor.discharge();
+ } else {
+ this->generate(
+ source.getNode(),
+ transformation,
+ target
+ );
+ }
+}
+
+void TransformerFacade::generate(
+ const xalan::XSLTInputSource& transformation,
+ xalan::FormatterListener& target
+) {
+ ErrorCapacitor errorCapacitor(&this->error_multiplexer_);
+
+ xercesc::DOMDocument* const inputDocument(
+ xercesc::DOMImplementation::getImplementation()->createDocument(
+ nullptr,
+ *XercesStringGuard<XMLCh>("dummy"),
+ nullptr
+ )
+ );
+
+ xalan::XercesParserLiaison parserLiaison;
+ xalan::XercesDOMSupport domSupport(parserLiaison);
+
+ xalan::XercesDOMWrapperParsedSource inputParsedSource(
+ inputDocument,
+ parserLiaison,
+ domSupport
+ );
+
+ this->transformer_.transform(
+ inputParsedSource,
+ transformation,
+ target
+ );
+
+ inputDocument->release();
+
+ errorCapacitor.discharge();
+}
+
+void TransformerFacade::generate(
+ xalan::XalanNode* const source,
+ const xalan::XSLTInputSource& transformation,
+ xalan::FormatterListener& target
+) {
+ ErrorCapacitor errorCapacitor(&this->error_multiplexer_);
+
+ xercesc::DOMDocument* const inputDocument(
+ xercesc::DOMImplementation::getImplementation()->createDocument()
+ );
+
+ xalan::FormatterToXercesDOM inputFormatter(
+ inputDocument,
+ inputDocument->getDocumentElement()
+ );
+
+ xalan::FormatterTreeWalker walker(inputFormatter);
+ walker.traverseSubtree(source);
+
+ xalan::XercesParserLiaison parserLiaison;
+ xalan::XercesDOMSupport domSupport(parserLiaison);
+
+ xalan::XercesDOMWrapperParsedSource inputParsedSource(
+ inputFormatter.getDocument(),
+ parserLiaison,
+ domSupport
+ );
+
+ this->transformer_.transform(
+ inputParsedSource,
+ transformation,
+ target
+ );
+
+ inputDocument->release();
+
+ errorCapacitor.discharge();
+}
+
+}
diff --git a/src/transformer_facade.h b/src/transformer_facade.h
new file mode 100644
index 0000000..17db094
--- /dev/null
+++ b/src/transformer_facade.h
@@ -0,0 +1,46 @@
+#ifndef INPUTXSLT_SRC_TRANSFORMER_FACADE_H_
+#define INPUTXSLT_SRC_TRANSFORMER_FACADE_H_
+
+#include <xalanc/XalanTransformer/XalanTransformer.hpp>
+
+#include "common.h"
+#include "support/include_entity_resolver.h"
+#include "support/error/error_multiplexer.h"
+#include "support/error/error_capacitor.h"
+#include "support/error/warning_capacitor.h"
+
+namespace InputXSLT {
+
+class TransformerFacade {
+ public:
+ TransformerFacade(IncludeEntityResolver*);
+
+ void generate(
+ const xalan::XSLTInputSource&,
+ const xalan::XSLTInputSource&,
+ xalan::FormatterListener&
+ );
+
+ void generate(
+ const xalan::XSLTInputSource&,
+ xalan::FormatterListener&
+ );
+
+ WarningCapacitor::warning_cache_ptr getCachedWarnings();
+
+ private:
+ xalan::XalanTransformer transformer_;
+ ErrorMultiplexer error_multiplexer_;
+ WarningCapacitor warning_capacitor_;
+
+ void generate(
+ xalan::XalanNode* const,
+ const xalan::XSLTInputSource&,
+ xalan::FormatterListener&
+ );
+
+};
+
+}
+
+#endif // INPUTXSLT_SRC_TRANSFORMER_FACADE_H_
diff --git a/test/transform/reference.xml b/test/transform/reference.xml
index e537bbc..1c702e8 100644
--- a/test/transform/reference.xml
+++ b/test/transform/reference.xml
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<test_case>
-<input_tree>
+<input_entries>
<entry>Hello 1</entry>
<entry>Hello 2</entry>
<entry>Hello 3</entry>
<entry>Hello 4</entry>
-</input_tree>
+</input_entries>
<parameter_value>42</parameter_value>
</test_case>
diff --git a/test/transform/test.xsl b/test/transform/test.xsl
index 7469f92..a9f04a5 100644
--- a/test/transform/test.xsl
+++ b/test/transform/test.xsl
@@ -14,16 +14,14 @@
indent="yes"
/>
-<xsl:param name="parameters"/>
-
<xsl:template match="test">
<test_case>
<transform_test>
- <input_tree>
- <xsl:copy-of select="./entry"/>
- </input_tree>
+ <input_entries>
+ <xsl:copy-of select="./entries/entry"/>
+ </input_entries>
<parameter_value>
- <xsl:copy-of select="$parameters/test * 2"/>
+ <xsl:value-of select="./parameter/test * 2"/>
</parameter_value>
</transform_test>
</test_case>
diff --git a/test/transform/transformation.xsl b/test/transform/transformation.xsl
index 686bbf5..1002540 100644
--- a/test/transform/transformation.xsl
+++ b/test/transform/transformation.xsl
@@ -23,12 +23,10 @@
<xsl:template name="transformer">
<xsl:param name="input"/>
<xsl:param name="transformation"/>
- <xsl:param name="parameters"/>
<xsl:copy-of select="InputXSLT:transform(
$input,
- $transformation,
- $parameters
+ $transformation
)"/>
</xsl:template>
@@ -36,13 +34,11 @@
<xsl:param name="input"/>
<xsl:param name="transformation"/>
<xsl:param name="target"/>
- <xsl:param name="parameters"/>
<xsl:variable name="transformerResult">
<xsl:call-template name="transformer">
- <xsl:with-param name="input" select="string($input)"/>
+ <xsl:with-param name="input" select="$input"/>
<xsl:with-param name="transformation" select="string($transformation)"/>
- <xsl:with-param name="parameters" select="xalan:nodeset($parameters)"/>
</xsl:call-template>
</xsl:variable>
@@ -62,12 +58,21 @@
<xsl:template name="implementation">
<xsl:variable name="result">
<xsl:call-template name="generator">
- <xsl:with-param name="input">[test.xml]</xsl:with-param>
+ <xsl:with-param name="input">
+ <test>
+ <entries>
+ <entry>Hello 1</entry>
+ <entry>Hello 2</entry>
+ <entry>Hello 3</entry>
+ <entry>Hello 4</entry>
+ </entries>
+ <parameter>
+ <test>21</test>
+ </parameter>
+ </test>
+ </xsl:with-param>
<xsl:with-param name="transformation">test.xsl</xsl:with-param>
<xsl:with-param name="target">test_actual.xml</xsl:with-param>
- <xsl:with-param name="parameters">
- <test>21</test>
- </xsl:with-param>
</xsl:call-template>
</xsl:variable>