diff options
author | Adrian Kummerländer | 2014-05-02 22:06:37 +0200 |
---|---|---|
committer | Adrian Kummerländer | 2014-05-02 22:06:37 +0200 |
commit | e5ed418907f09bf8905463f42a44593d51159bc9 (patch) | |
tree | 25d70d23625877946486ce8d46d7c4fb98a836f9 /src/function/read_file.cc | |
parent | e9c4e2b716798002c9ccbf96ee509eb91ad56553 (diff) | |
download | InputXSLT-e5ed418907f09bf8905463f42a44593d51159bc9.tar InputXSLT-e5ed418907f09bf8905463f42a44593d51159bc9.tar.gz InputXSLT-e5ed418907f09bf8905463f42a44593d51159bc9.tar.bz2 InputXSLT-e5ed418907f09bf8905463f42a44593d51159bc9.tar.lz InputXSLT-e5ed418907f09bf8905463f42a44593d51159bc9.tar.xz InputXSLT-e5ed418907f09bf8905463f42a44593d51159bc9.tar.zst InputXSLT-e5ed418907f09bf8905463f42a44593d51159bc9.zip |
Changed external functions to enable global installation
* up until now all external functions were locally installed to a specific XalanTransformer instance contained within a TransformationGuard instance
** this had to change as I planned to add a "execute-transformation" function based on TransformationGuard which would have led to recursive self-instantiation
** global external functions have to be thread-safe
* as global external function can not be provided with a reference to a transformation-specific FilesystemFacade instance, the working path is now determined using xalan::Locator
** currently using pointer arithmetics on XMLCh* to remove the "file://" prefix of the URI returned by locator->getSystemId(), may be unsafe
* added compilation unit for PlattformGuard as it now contains function installation in addition to plattform lifetime management
Diffstat (limited to 'src/function/read_file.cc')
-rw-r--r-- | src/function/read_file.cc | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/function/read_file.cc b/src/function/read_file.cc index f531191..7634d54 100644 --- a/src/function/read_file.cc +++ b/src/function/read_file.cc @@ -8,6 +8,7 @@ #include "boost/filesystem/fstream.hpp" #include "support/xerces_string_guard.h" +#include "support/filesystem_context.h" namespace { @@ -24,18 +25,23 @@ inline std::string readFile(const boost::filesystem::path& filePath) { namespace InputXSLT { -FunctionReadFile::FunctionReadFile(const FilesystemContext& context): - fs_context_(context), +FunctionReadFile::FunctionReadFile(): document_cache_(std::make_shared<DomDocumentCache>()) { } xalan::XObjectPtr FunctionReadFile::execute( xalan::XPathExecutionContext& executionContext, xalan::XalanNode*, const xalan::XObjectPtr argument, - const xalan::Locator* + const xalan::Locator* locator ) const { + const FilesystemContext fs_context( + boost::filesystem::path( + xercesc::XMLString::transcode(locator->getSystemId() + 7) + ).parent_path().string() + ); + const boost::filesystem::path filePath( - this->fs_context_.resolve(argument->str()) + fs_context.resolve(argument->str()) ); DomDocumentCache::item* const cachedDocument( |