aboutsummaryrefslogtreecommitdiff
path: root/src/plattform_guard.cc
diff options
context:
space:
mode:
authorAdrian Kummerländer2014-05-02 22:06:37 +0200
committerAdrian Kummerländer2014-05-02 22:06:37 +0200
commite5ed418907f09bf8905463f42a44593d51159bc9 (patch)
tree25d70d23625877946486ce8d46d7c4fb98a836f9 /src/plattform_guard.cc
parente9c4e2b716798002c9ccbf96ee509eb91ad56553 (diff)
downloadInputXSLT-e5ed418907f09bf8905463f42a44593d51159bc9.tar
InputXSLT-e5ed418907f09bf8905463f42a44593d51159bc9.tar.gz
InputXSLT-e5ed418907f09bf8905463f42a44593d51159bc9.tar.bz2
InputXSLT-e5ed418907f09bf8905463f42a44593d51159bc9.tar.lz
InputXSLT-e5ed418907f09bf8905463f42a44593d51159bc9.tar.xz
InputXSLT-e5ed418907f09bf8905463f42a44593d51159bc9.tar.zst
InputXSLT-e5ed418907f09bf8905463f42a44593d51159bc9.zip
Changed external functions to enable global installation
* up until now all external functions were locally installed to a specific XalanTransformer instance contained within a TransformationGuard instance ** this had to change as I planned to add a "execute-transformation" function based on TransformationGuard which would have led to recursive self-instantiation ** global external functions have to be thread-safe * as global external function can not be provided with a reference to a transformation-specific FilesystemFacade instance, the working path is now determined using xalan::Locator ** currently using pointer arithmetics on XMLCh* to remove the "file://" prefix of the URI returned by locator->getSystemId(), may be unsafe * added compilation unit for PlattformGuard as it now contains function installation in addition to plattform lifetime management
Diffstat (limited to 'src/plattform_guard.cc')
-rw-r--r--src/plattform_guard.cc46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/plattform_guard.cc b/src/plattform_guard.cc
new file mode 100644
index 0000000..2c3cee4
--- /dev/null
+++ b/src/plattform_guard.cc
@@ -0,0 +1,46 @@
+#include "plattform_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/read_xml_file.h"
+#include "function/read_directory.h"
+
+namespace InputXSLT {
+
+PlattformGuard::PlattformGuard() {
+ xercesc::XMLPlatformUtils::Initialize();
+ xalan::XalanTransformer::initialize();
+
+ const xalan::XalanDOMString customNamespace(
+ "function.inputxslt.application"
+ );
+
+ xalan::XalanTransformer::installExternalFunctionGlobal(
+ customNamespace,
+ xalan::XalanDOMString("read-file"),
+ InputXSLT::FunctionReadFile()
+ );
+
+ xalan::XalanTransformer::installExternalFunctionGlobal(
+ customNamespace,
+ xalan::XalanDOMString("read-xml-file"),
+ InputXSLT::FunctionReadXmlFile()
+ );
+
+ xalan::XalanTransformer::installExternalFunctionGlobal(
+ customNamespace,
+ xalan::XalanDOMString("read-directory"),
+ InputXSLT::FunctionReadDirectory()
+ );
+}
+
+PlattformGuard::~PlattformGuard() {
+ xalan::XalanTransformer::terminate();
+}
+
+}