aboutsummaryrefslogtreecommitdiff
path: root/src/platform_guard.cc
blob: f50d976659449884703958f4a48f2412a82f30b2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
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_command.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-command"),
		InputXSLT::FunctionExternalCommand(&this->include_resolver_)
	);
}

PlatformGuard::~PlatformGuard() {
	xalan::XalanTransformer::terminate();
}

IncludeEntityResolver* PlatformGuard::getEntityResolver() {
	return &this->include_resolver_;
}

}