aboutsummaryrefslogtreecommitdiff
path: root/src/transformer_guard.cc
diff options
context:
space:
mode:
authorAdrian Kummerländer2014-04-19 18:31:15 +0200
committerAdrian Kummerländer2014-04-19 18:31:15 +0200
commit3383e24e396431eed7d4ab9f69ff8ffaf12d4925 (patch)
tree8cedb029eee462dd8145077aee98db593ef6d62d /src/transformer_guard.cc
parent334efe3383c436d61a8e5dd95b923cb0d5db9652 (diff)
downloadInputXSLT-3383e24e396431eed7d4ab9f69ff8ffaf12d4925.tar
InputXSLT-3383e24e396431eed7d4ab9f69ff8ffaf12d4925.tar.gz
InputXSLT-3383e24e396431eed7d4ab9f69ff8ffaf12d4925.tar.bz2
InputXSLT-3383e24e396431eed7d4ab9f69ff8ffaf12d4925.tar.lz
InputXSLT-3383e24e396431eed7d4ab9f69ff8ffaf12d4925.tar.xz
InputXSLT-3383e24e396431eed7d4ab9f69ff8ffaf12d4925.tar.zst
InputXSLT-3383e24e396431eed7d4ab9f69ff8ffaf12d4925.zip
Implemented transformation execution function
* InputXSLT::PlattformGuard handles xerces and xalan construction and lifetime * InputXSLT::TransformerGuard instantiates PlattformGuard, configurates external functions ** offers execute method for "executing" a XSL tranformation with empty input
Diffstat (limited to 'src/transformer_guard.cc')
-rw-r--r--src/transformer_guard.cc67
1 files changed, 67 insertions, 0 deletions
diff --git a/src/transformer_guard.cc b/src/transformer_guard.cc
new file mode 100644
index 0000000..73bcea2
--- /dev/null
+++ b/src/transformer_guard.cc
@@ -0,0 +1,67 @@
+#include "transformer_guard.h"
+
+#include <xalanc/Include/PlatformDefinitions.hpp>
+#include <xercesc/util/PlatformUtils.hpp>
+
+#include <xalanc/XSLT/XSLTInputSource.hpp>
+#include <xalanc/XalanTransformer/XalanTransformer.hpp>
+#include <xalanc/XalanTransformer/XercesDOMWrapperParsedSource.hpp>
+#include <xalanc/XercesParserLiaison/XercesDOMSupport.hpp>
+
+#include <xercesc/dom/DOMDocument.hpp>
+#include <xercesc/dom/DOMImplementation.hpp>
+
+#include "function/read_file.h"
+#include "function/read_xml_file.h"
+
+namespace InputXSLT {
+
+TransformerGuard::TransformerGuard():
+ plattform_(),
+ parser_(),
+ transformer_() {
+ const xalan::XalanDOMString customNamespace(
+ "http://ExternalFunction.xalan-c++.xml.apache.org"
+ );
+
+ this->transformer_.installExternalFunction(
+ customNamespace,
+ xalan::XalanDOMString("read-file"),
+ InputXSLT::FunctionReadFile()
+ );
+
+ this->transformer_.installExternalFunction(
+ customNamespace,
+ xalan::XalanDOMString("read-xml-file"),
+ InputXSLT::FunctionReadXmlFile()
+ );
+
+}
+
+int TransformerGuard::execute(
+ const std::string& transformation,
+ const std::string& target
+) {
+ xercesc::DOMDocument* inputDom(
+ xercesc::DOMImplementation::getImplementation()->createDocument()
+ );
+ xalan::XercesDOMSupport domSupport(this->parser_);
+
+ xalan::XercesDOMWrapperParsedSource parsedInput(
+ inputDom,
+ this->parser_,
+ domSupport,
+ xalan::XalanDOMString("")
+ );
+
+ xalan::XSLTInputSource transform(transformation.data());
+ xalan::XSLTResultTarget output(target.data());
+
+ return this->transformer_.transform(
+ parsedInput,
+ transform,
+ output
+ );
+}
+
+}