aboutsummaryrefslogtreecommitdiff
path: root/src/platform_guard.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/platform_guard.cc')
-rw-r--r--src/platform_guard.cc72
1 files changed, 72 insertions, 0 deletions
diff --git a/src/platform_guard.cc b/src/platform_guard.cc
new file mode 100644
index 0000000..6be5b4a
--- /dev/null
+++ b/src/platform_guard.cc
@@ -0,0 +1,72 @@
+#include "platform_guard.h"
+
+#include <xalanc/Include/PlatformDefinitions.hpp>
+#include <xalanc/XalanTransformer/XalanTransformer.hpp>
+
+#include <xercesc/util/PlatformUtils.hpp>
+
+#include "common.h"
+#include "function/read_file.h"
+#include "function/write_file.h"
+#include "function/read_directory.h"
+#include "function/transform.h"
+#include "function/generate.h"
+#include "function/external_text_formatter.h"
+
+namespace InputXSLT {
+
+PlatformGuard::PlatformGuard(const std::vector<std::string>& path):
+ include_resolver_(path) {
+ xercesc::XMLPlatformUtils::Initialize();
+ xalan::XalanTransformer::initialize();
+
+ const xalan::XalanDOMString customNamespace(
+ "function.inputxslt.application"
+ );
+
+ xalan::XalanTransformer::installExternalFunctionGlobal(
+ customNamespace,
+ xalan::XalanDOMString("read-file"),
+ InputXSLT::FunctionReadFile(&this->include_resolver_)
+ );
+
+ xalan::XalanTransformer::installExternalFunctionGlobal(
+ customNamespace,
+ xalan::XalanDOMString("write-file"),
+ InputXSLT::FunctionWriteFile(&this->include_resolver_)
+ );
+
+ xalan::XalanTransformer::installExternalFunctionGlobal(
+ customNamespace,
+ xalan::XalanDOMString("read-directory"),
+ InputXSLT::FunctionReadDirectory(&this->include_resolver_)
+ );
+
+ xalan::XalanTransformer::installExternalFunctionGlobal(
+ customNamespace,
+ xalan::XalanDOMString("transform"),
+ InputXSLT::FunctionTransform(&this->include_resolver_)
+ );
+
+ xalan::XalanTransformer::installExternalFunctionGlobal(
+ customNamespace,
+ xalan::XalanDOMString("generate"),
+ InputXSLT::FunctionGenerate(&this->include_resolver_)
+ );
+
+ xalan::XalanTransformer::installExternalFunctionGlobal(
+ customNamespace,
+ xalan::XalanDOMString("external-text-formatter"),
+ InputXSLT::FunctionExternalTextFormatter(&this->include_resolver_)
+ );
+}
+
+PlatformGuard::~PlatformGuard() {
+ xalan::XalanTransformer::terminate();
+}
+
+IncludeEntityResolver* PlatformGuard::getEntityResolver() {
+ return &this->include_resolver_;
+}
+
+}