aboutsummaryrefslogtreecommitdiff
path: root/src/function
diff options
context:
space:
mode:
authorAdrian Kummerländer2014-04-20 13:09:32 +0200
committerAdrian Kummerländer2014-04-20 13:09:32 +0200
commit29a9fb20b4c8414f2590886e43ae86794a53db89 (patch)
tree4d426d45293a019caee8ee879186111c90b426d3 /src/function
parent3383e24e396431eed7d4ab9f69ff8ffaf12d4925 (diff)
downloadInputXSLT-29a9fb20b4c8414f2590886e43ae86794a53db89.tar
InputXSLT-29a9fb20b4c8414f2590886e43ae86794a53db89.tar.gz
InputXSLT-29a9fb20b4c8414f2590886e43ae86794a53db89.tar.bz2
InputXSLT-29a9fb20b4c8414f2590886e43ae86794a53db89.tar.lz
InputXSLT-29a9fb20b4c8414f2590886e43ae86794a53db89.tar.xz
InputXSLT-29a9fb20b4c8414f2590886e43ae86794a53db89.tar.zst
InputXSLT-29a9fb20b4c8414f2590886e43ae86794a53db89.zip
Implemented support for modifying external function base path
* one expects a read-file function to work relative to the directory the transformation is located and not to the executable's location ** from the perspective of the user the transformation is the application, not the actual executable * removed PlattformGuard struct from TransformerGuard (now TransformerFacade) * TransformerFacade is instatiated with the appropriate relative working path ** i.e. it will have to be instantiated for every directory containing one or more transformations
Diffstat (limited to 'src/function')
-rw-r--r--src/function/read_file.cc20
-rw-r--r--src/function/read_file.h8
-rw-r--r--src/function/read_xml_file.cc11
-rw-r--r--src/function/read_xml_file.h7
4 files changed, 33 insertions, 13 deletions
diff --git a/src/function/read_file.cc b/src/function/read_file.cc
index efc1f61..dcbff25 100644
--- a/src/function/read_file.cc
+++ b/src/function/read_file.cc
@@ -1,7 +1,12 @@
#include "read_file.h"
+#include "utility.h"
+
namespace InputXSLT {
+FunctionReadFile::FunctionReadFile(const std::string& path):
+ path_(path) { }
+
xalan::XObjectPtr FunctionReadFile::execute(
xalan::XPathExecutionContext& executionContext,
xalan::XalanNode* context,
@@ -16,20 +21,21 @@ xalan::XObjectPtr FunctionReadFile::execute(
generalError(executionContext, context, locator);
}
- xalan::CharVectorType fileNameVector;
- std::string fileNameString;
+ xalan::CharVectorType castHelper;
+ arguments[0]->str().transcode(castHelper);
- arguments[0]->str().transcode(fileNameVector);
+ std::string fileName(this->path_);
+ fileName.reserve(fileName.size() + castHelper.size());
std::move(
- fileNameVector.begin(),
- fileNameVector.end(),
- fileNameString.begin()
+ castHelper.begin(),
+ castHelper.end(),
+ fileName.end()
);
return executionContext.getXObjectFactory().createString(
xalan::XalanDOMString(
- InputXSLT::readFile(fileNameString).data()
+ InputXSLT::readFile(fileName).data()
)
);
}
diff --git a/src/function/read_file.h b/src/function/read_file.h
index dbcf3d6..f800c37 100644
--- a/src/function/read_file.h
+++ b/src/function/read_file.h
@@ -8,12 +8,16 @@
#include <xalanc/XPath/Function.hpp>
#include <xalanc/XPath/XObject.hpp>
-#include "utility.h"
+#include <string>
+
+#include "common.h"
namespace InputXSLT {
class FunctionReadFile : public xalan::Function {
public:
+ FunctionReadFile(const std::string&);
+
virtual xalan::XObjectPtr execute(
xalan::XPathExecutionContext&,
xalan::XalanNode*,
@@ -27,6 +31,8 @@ class FunctionReadFile : public xalan::Function {
bool operator==(const FunctionReadFile&) const = delete;
private:
+ const std::string path_;
+
const xalan::XalanDOMString& getError(xalan::XalanDOMString&) const;
};
diff --git a/src/function/read_xml_file.cc b/src/function/read_xml_file.cc
index 616d189..be091a0 100644
--- a/src/function/read_xml_file.cc
+++ b/src/function/read_xml_file.cc
@@ -2,10 +2,12 @@
namespace InputXSLT {
-FunctionReadXmlFile::FunctionReadXmlFile():
+FunctionReadXmlFile::FunctionReadXmlFile(const std::string& path):
+ path_(path),
parser_() { }
-FunctionReadXmlFile::FunctionReadXmlFile(const FunctionReadXmlFile&):
+FunctionReadXmlFile::FunctionReadXmlFile(const FunctionReadXmlFile& src):
+ path_(src.path_),
parser_() { }
xalan::XObjectPtr FunctionReadXmlFile::execute(
@@ -22,9 +24,12 @@ xalan::XObjectPtr FunctionReadXmlFile::execute(
generalError(executionContext, context, locator);
}
+ xalan::XalanDOMString fileName(this->path_.data());
+ fileName.append(arguments[0]->str());
+
return executionContext.getXObjectFactory().createNodeSet(
this->parser_.parseXMLStream(
- xalan::XSLTInputSource(arguments[0]->str())
+ xalan::XSLTInputSource(fileName)
)
);
}
diff --git a/src/function/read_xml_file.h b/src/function/read_xml_file.h
index 1556764..c755852 100644
--- a/src/function/read_xml_file.h
+++ b/src/function/read_xml_file.h
@@ -9,13 +9,15 @@
#include <xalanc/XPath/XObject.hpp>
#include <xalanc/XercesParserLiaison/XercesParserLiaison.hpp>
-#include "utility.h"
+#include <string>
+
+#include "common.h"
namespace InputXSLT {
class FunctionReadXmlFile : public xalan::Function {
public:
- FunctionReadXmlFile();
+ FunctionReadXmlFile(const std::string&);
FunctionReadXmlFile(const FunctionReadXmlFile&);
virtual xalan::XObjectPtr execute(
@@ -31,6 +33,7 @@ class FunctionReadXmlFile : public xalan::Function {
bool operator==(const FunctionReadXmlFile&) const = delete;
private:
+ const std::string path_;
mutable xalan::XercesParserLiaison parser_;
const xalan::XalanDOMString& getError(xalan::XalanDOMString& result) const;