blob: 96b6c5d851d36286a1412362f7dd4da039e951a0 (
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
|
#include <xalanc/Include/PlatformDefinitions.hpp>
#include <xercesc/util/PlatformUtils.hpp>
#include <xalanc/XalanTransformer/XalanTransformer.hpp>
#include <xalanc/XPath/XObjectFactory.hpp>
#include <xalanc/XPath/Function.hpp>
#include <xalanc/XPath/XObject.hpp>
#include <xalanc/XercesParserLiaison/XercesParserLiaison.hpp>
#include "utility.h"
namespace xalan = xalanc_1_11;
class FunctionReadXmlFile : public xalan::Function {
public:
virtual xalan::XObjectPtr execute(
xalan::XPathExecutionContext& executionContext,
xalan::XalanNode* context,
const xalan::Function::XObjectArgVectorType& args,
const xalan::Locator* locator
) const {
if ( args.size() != 1 ) {
xalan::XPathExecutionContext::GetAndReleaseCachedString guard(
executionContext
);
generalError(executionContext, context, locator);
}
if ( this->liaison == nullptr ) {
const_cast<FunctionReadXmlFile*>(this)->liaison = new xalan::XercesParserLiaison();
}
xalan::XSLTInputSource file(args[0]->str());
return executionContext.getXObjectFactory().createNodeSet(
liaison->parseXMLStream(file)
);
}
virtual FunctionReadXmlFile* clone(xalan::MemoryManager& manager) const {
return xalan::XalanCopyConstruct(manager, *this);
}
protected:
xalan::XercesParserLiaison* liaison = nullptr;
const xalan::XalanDOMString& getError(xalan::XalanDOMString& result) const {
result.assign("The read-file() function expects one argument.");
return result;
}
private:
FunctionReadXmlFile& operator=(const FunctionReadXmlFile&);
bool operator==(const FunctionReadXmlFile&) const;
};
|