aboutsummaryrefslogtreecommitdiff
path: root/src/function
diff options
context:
space:
mode:
Diffstat (limited to 'src/function')
-rw-r--r--src/function/resolve_include.cc62
-rw-r--r--src/function/resolve_include.h44
-rw-r--r--src/function/transform.cc9
-rw-r--r--src/function/transform.h7
4 files changed, 14 insertions, 108 deletions
diff --git a/src/function/resolve_include.cc b/src/function/resolve_include.cc
deleted file mode 100644
index ac4adf5..0000000
--- a/src/function/resolve_include.cc
+++ /dev/null
@@ -1,62 +0,0 @@
-#include "resolve_include.h"
-
-#include <algorithm>
-
-#include "support/xalan_string.h"
-
-namespace InputXSLT {
-
-FunctionResolveInclude::FunctionResolveInclude(
- const std::vector<std::string>& path):
- path_(new std::vector<FilesystemContext>()) {
- this->path_->reserve(path.size());
-
- std::transform(
- path.begin(),
- path.end(),
- std::back_inserter(*this->path_),
- [](const std::string& path) -> FilesystemContext {
- return FilesystemContext(path);
- }
- );
-}
-
-xalan::XObjectPtr FunctionResolveInclude::execute(
- xalan::XPathExecutionContext& executionContext,
- xalan::XalanNode*,
- const xalan::XObjectPtr parameter,
- const xalan::Locator*
-) const {
- const std::string filePath(toString(parameter->str()));
-
- for ( auto&& context : *this->path_ ) {
- const boost::filesystem::path resolvedPath(
- context.resolve(filePath)
- );
-
- if ( boost::filesystem::exists(resolvedPath) &&
- boost::filesystem::is_regular_file(resolvedPath) ) {
- return executionContext.getXObjectFactory().createString(
- toString(resolvedPath.string())
- );
- }
- }
-
- return executionContext.getXObjectFactory().createString(
- toString("error")
- );
-}
-
-FunctionResolveInclude* FunctionResolveInclude::clone(
- xalan::MemoryManager& manager) const {
- return xalan::XalanCopyConstruct(manager, *this);
-}
-
-const xalan::XalanDOMString& FunctionResolveInclude::getError(
- xalan::XalanDOMString& result) const {
- result.assign("The function expects one parameter of type string.");
-
- return result;
-}
-
-}
diff --git a/src/function/resolve_include.h b/src/function/resolve_include.h
deleted file mode 100644
index 2d6e62f..0000000
--- a/src/function/resolve_include.h
+++ /dev/null
@@ -1,44 +0,0 @@
-#ifndef INPUTXSLT_SRC_FUNCTION_RESOLVE_INCLUDE_H_
-#define INPUTXSLT_SRC_FUNCTION_RESOLVE_INCLUDE_H_
-
-#include <xalanc/XPath/XObjectFactory.hpp>
-#include <xalanc/XPath/Function.hpp>
-#include <xalanc/XPath/XObject.hpp>
-
-#include "boost/filesystem.hpp"
-
-#include <memory>
-#include <string>
-#include <vector>
-
-#include "common.h"
-#include "support/filesystem_context.h"
-
-namespace InputXSLT {
-
-class FunctionResolveInclude : public xalan::Function {
- public:
- FunctionResolveInclude(const std::vector<std::string>&);
-
- virtual xalan::XObjectPtr execute(
- xalan::XPathExecutionContext&,
- xalan::XalanNode*,
- const xalan::XObjectPtr,
- const xalan::Locator*
- ) const;
-
- virtual FunctionResolveInclude* clone(xalan::MemoryManager&) const;
-
- FunctionResolveInclude& operator=(const FunctionResolveInclude&) = delete;
- bool operator==(const FunctionResolveInclude&) const = delete;
-
- private:
- const std::shared_ptr<std::vector<FilesystemContext>> path_;
-
- const xalan::XalanDOMString& getError(xalan::XalanDOMString&) const;
-
-};
-
-}
-
-#endif // INPUTXSLT_SRC_FUNCTION_RESOLVE_INCLUDE_H_
diff --git a/src/function/transform.cc b/src/function/transform.cc
index 6a2b7ad..8823745 100644
--- a/src/function/transform.cc
+++ b/src/function/transform.cc
@@ -9,6 +9,10 @@
namespace InputXSLT {
+FunctionTransform::FunctionTransform(IncludeEntityResolver* resolver):
+ FunctionBase::FunctionBase(),
+ include_resolver_(resolver) { }
+
xercesc::DOMDocument* FunctionTransform::constructDocument(
const InputXSLT::FilesystemContext& fsContext,
const FunctionBase::parameter_tuple& parameters
@@ -37,7 +41,10 @@ xercesc::DOMDocument* FunctionTransform::constructDocument(
domDocument->getDocumentElement()
);
- InputXSLT::TransformationFacade transformation(transformationPath);
+ InputXSLT::TransformationFacade transformation(
+ transformationPath,
+ this->include_resolver_
+ );
if ( transformation.generate(targetPath, parameterObject) == 0 ) {
xercesc::DOMElement* const resultNode(
diff --git a/src/function/transform.h b/src/function/transform.h
index 810738e..94fae53 100644
--- a/src/function/transform.h
+++ b/src/function/transform.h
@@ -3,6 +3,8 @@
#include "base.h"
+#include "support/include_entity_resolver.h"
+
namespace InputXSLT {
class FunctionTransform : public FunctionBase<
@@ -12,7 +14,7 @@ class FunctionTransform : public FunctionBase<
xalan::XObjectPtr
> {
public:
- using FunctionBase::FunctionBase;
+ FunctionTransform(IncludeEntityResolver*);
protected:
friend FunctionBase;
@@ -22,6 +24,9 @@ class FunctionTransform : public FunctionBase<
const FunctionBase::parameter_tuple&
);
+ private:
+ IncludeEntityResolver* const include_resolver_;
+
};
}