diff options
author | Adrian Kummerlaender | 2014-06-17 21:28:04 +0200 |
---|---|---|
committer | Adrian Kummerlaender | 2014-06-17 21:28:04 +0200 |
commit | 0d670478b51c55e44f57995fe3ca8a4585723a6c (patch) | |
tree | 8014505de42d1743599d8076c503e9f3c6e22e8f /src/function | |
parent | 741a70f5fecc38033832728f4ecc62a6abe328b2 (diff) | |
download | InputXSLT-0d670478b51c55e44f57995fe3ca8a4585723a6c.tar InputXSLT-0d670478b51c55e44f57995fe3ca8a4585723a6c.tar.gz InputXSLT-0d670478b51c55e44f57995fe3ca8a4585723a6c.tar.bz2 InputXSLT-0d670478b51c55e44f57995fe3ca8a4585723a6c.tar.lz InputXSLT-0d670478b51c55e44f57995fe3ca8a4585723a6c.tar.xz InputXSLT-0d670478b51c55e44f57995fe3ca8a4585723a6c.tar.zst InputXSLT-0d670478b51c55e44f57995fe3ca8a4585723a6c.zip |
Added context awareness to XObjectValue casting logic
* added support for defining boost::filesystem::path as a external function parameter
** boost::filesystem::path parameters are resolved against the appropriate FilesystemContext and IncludeEntityResolver instances
* xalan::XSLTInputSource parameter source paths are also resolved
* removed need for passing a reference FilesystemContext to "constructDocument" methods
** they now only accept the parameters of the external function implemented by them
** all path resolution logic is wrapped by the newly created XObjectValue class
* converted XObjectValue namespace into class
** the "get" template method is now a template member method
** this was needed to enable value casting logic to access the appropriate FilesystemContext and IncludeEntityResolver instances
* this commit marks the next step towards the goals defined in 741a70f
Diffstat (limited to 'src/function')
-rw-r--r-- | src/function/base.h | 14 | ||||
-rw-r--r-- | src/function/external_text_formatter.cc | 1 | ||||
-rw-r--r-- | src/function/external_text_formatter.h | 1 | ||||
-rw-r--r-- | src/function/read_directory.cc | 10 | ||||
-rw-r--r-- | src/function/read_directory.h | 9 | ||||
-rw-r--r-- | src/function/read_file.cc | 13 | ||||
-rw-r--r-- | src/function/read_file.h | 9 | ||||
-rw-r--r-- | src/function/transform.cc | 11 | ||||
-rw-r--r-- | src/function/transform.h | 7 |
9 files changed, 28 insertions, 47 deletions
diff --git a/src/function/base.h b/src/function/base.h index 5212d65..5aada0e 100644 --- a/src/function/base.h +++ b/src/function/base.h @@ -96,16 +96,18 @@ class FunctionBase : public xalan::Function { const xalan::Locator* locator, Sequence<Index...> ) const { + XObjectValue valueGetter( + this->include_resolver_->resolve( + locator->getSystemId() + ), + this->include_resolver_ + ); + return this->document_cache_->create( static_cast<Implementation*>( const_cast<FunctionBase*>(this) )->constructDocument( - FilesystemContext( - this->include_resolver_->resolve( - locator->getSystemId() - ) - ), - XObjectValue::get<typename std::tuple_element< + valueGetter.get<typename std::tuple_element< Index, std::tuple<Types...> >::type>(parameters[Index])... diff --git a/src/function/external_text_formatter.cc b/src/function/external_text_formatter.cc index 4171ded..b2f9d33 100644 --- a/src/function/external_text_formatter.cc +++ b/src/function/external_text_formatter.cc @@ -43,7 +43,6 @@ inline xercesc::DOMNode* importDocumentElement( namespace InputXSLT { xercesc::DOMDocument* FunctionExternalTextFormatter::constructDocument( - const InputXSLT::FilesystemContext&, std::string formatterPath, std::string stdinText ) { diff --git a/src/function/external_text_formatter.h b/src/function/external_text_formatter.h index 95ff127..3af1d52 100644 --- a/src/function/external_text_formatter.h +++ b/src/function/external_text_formatter.h @@ -17,7 +17,6 @@ class FunctionExternalTextFormatter : public FunctionBase< friend FunctionBase; xercesc::DOMDocument* constructDocument( - const FilesystemContext&, std::string, std::string ); diff --git a/src/function/read_directory.cc b/src/function/read_directory.cc index cfbe302..884963e 100644 --- a/src/function/read_directory.cc +++ b/src/function/read_directory.cc @@ -10,13 +10,7 @@ namespace InputXSLT { xercesc::DOMDocument* FunctionReadDirectory::constructDocument( - const InputXSLT::FilesystemContext& fsContext, - std::string path -) { - const boost::filesystem::path directoryPath( - fsContext.resolve(path) - ); - + boost::filesystem::path directoryPath) { xercesc::DOMDocument* const domDocument( xercesc::DOMImplementation::getImplementation()->createDocument( nullptr, @@ -37,7 +31,7 @@ xercesc::DOMDocument* FunctionReadDirectory::constructDocument( xercesc::DOMNode* const resultNode = result.getNode(); - fsContext.iterate( + FilesystemContext::iterate( directoryPath, [&domDocument, &resultNode](const boost::filesystem::path& p) { ResultNodeFacade result(domDocument, resultNode, "entry"); diff --git a/src/function/read_directory.h b/src/function/read_directory.h index 6366a09..41976d5 100644 --- a/src/function/read_directory.h +++ b/src/function/read_directory.h @@ -1,13 +1,15 @@ #ifndef INPUTXSLT_SRC_FUNCTION_READ_DIRECTORY_H_ #define INPUTXSLT_SRC_FUNCTION_READ_DIRECTORY_H_ +#include "boost/filesystem.hpp" + #include "base.h" namespace InputXSLT { class FunctionReadDirectory : public FunctionBase< FunctionReadDirectory, - std::string + boost::filesystem::path > { public: using FunctionBase::FunctionBase; @@ -15,10 +17,7 @@ class FunctionReadDirectory : public FunctionBase< protected: friend FunctionBase; - xercesc::DOMDocument* constructDocument( - const FilesystemContext&, - std::string - ); + xercesc::DOMDocument* constructDocument(boost::filesystem::path); }; diff --git a/src/function/read_file.cc b/src/function/read_file.cc index 1ea76c7..96e677f 100644 --- a/src/function/read_file.cc +++ b/src/function/read_file.cc @@ -49,18 +49,7 @@ inline std::string readPlainFile(const boost::filesystem::path& filePath) { namespace InputXSLT { xercesc::DOMDocument* FunctionReadFile::constructDocument( - const FilesystemContext& fsContext, - std::string rawPath -) { - boost::filesystem::path filePath(fsContext.resolve(rawPath)); - - if ( !(boost::filesystem::exists(filePath) && - boost::filesystem::is_regular_file(filePath)) ) { - if ( auto resolvedPath = this->include_resolver_->resolve(rawPath) ) { - filePath = *resolvedPath; - } - } - + boost::filesystem::path filePath) { xercesc::DOMDocument* const domDocument( xercesc::DOMImplementation::getImplementation()->createDocument( nullptr, diff --git a/src/function/read_file.h b/src/function/read_file.h index fec8fe2..9c2185a 100644 --- a/src/function/read_file.h +++ b/src/function/read_file.h @@ -1,13 +1,15 @@ #ifndef INPUTXSLT_SRC_FUNCTION_READ_FILE_H_ #define INPUTXSLT_SRC_FUNCTION_READ_FILE_H_ +#include "boost/filesystem.hpp" + #include "base.h" namespace InputXSLT { class FunctionReadFile : public FunctionBase< FunctionReadFile, - std::string + boost::filesystem::path > { public: using FunctionBase::FunctionBase; @@ -15,10 +17,7 @@ class FunctionReadFile : public FunctionBase< protected: friend FunctionBase; - xercesc::DOMDocument* constructDocument( - const FilesystemContext&, - std::string - ); + xercesc::DOMDocument* constructDocument(boost::filesystem::path); }; diff --git a/src/function/transform.cc b/src/function/transform.cc index 62b89ba..3ab6475 100644 --- a/src/function/transform.cc +++ b/src/function/transform.cc @@ -29,10 +29,9 @@ inline std::function<void(const ErrorCapacitor::error_cache&)> handleErrors( namespace InputXSLT { xercesc::DOMDocument* FunctionTransform::constructDocument( - const InputXSLT::FilesystemContext& fsContext, - xalan::XSLTInputSource transformationSource, - std::string targetPath, - xalan::XObjectPtr parameterObject + xalan::XSLTInputSource transformationSource, + boost::filesystem::path targetPath, + xalan::XObjectPtr parameterObject ) { xercesc::DOMDocument* const domDocument( xercesc::DOMImplementation::getImplementation()->createDocument( @@ -50,7 +49,7 @@ xercesc::DOMDocument* FunctionTransform::constructDocument( result.setAttribute( "target", - boost::filesystem::path(targetPath).filename().string() + targetPath.filename().string() ); if ( auto transformation = TransformationFacade::try_create( @@ -60,7 +59,7 @@ xercesc::DOMDocument* FunctionTransform::constructDocument( ) ) { try { transformation->generate( - fsContext.resolve(targetPath).string(), + targetPath.string(), parameterObject ); diff --git a/src/function/transform.h b/src/function/transform.h index 081fe90..516233f 100644 --- a/src/function/transform.h +++ b/src/function/transform.h @@ -3,6 +3,8 @@ #include <xalanc/XSLT/XSLTInputSource.hpp> +#include "boost/filesystem.hpp" + #include "base.h" namespace InputXSLT { @@ -10,7 +12,7 @@ namespace InputXSLT { class FunctionTransform : public FunctionBase< FunctionTransform, xalan::XSLTInputSource, - std::string, + boost::filesystem::path, xalan::XObjectPtr > { public: @@ -20,9 +22,8 @@ class FunctionTransform : public FunctionBase< friend FunctionBase; xercesc::DOMDocument* constructDocument( - const FilesystemContext&, xalan::XSLTInputSource, - std::string, + boost::filesystem::path, xalan::XObjectPtr ); |