blob: 73bcea240fb69a94118c1461bf338d1840ee5326 (
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
|
#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
);
}
}
|