diff options
Diffstat (limited to 'src/function/read_file.cc')
-rw-r--r-- | src/function/read_file.cc | 65 |
1 files changed, 6 insertions, 59 deletions
diff --git a/src/function/read_file.cc b/src/function/read_file.cc index ba94909..439d905 100644 --- a/src/function/read_file.cc +++ b/src/function/read_file.cc @@ -8,12 +8,9 @@ #include "boost/filesystem/fstream.hpp" #include "support/xerces_string_guard.h" -#include "support/filesystem_context.h" namespace { -using InputXSLT::XercesStringGuard; - inline std::string readFile(const boost::filesystem::path& filePath) { boost::filesystem::ifstream file(filePath); @@ -23,7 +20,12 @@ inline std::string readFile(const boost::filesystem::path& filePath) { ); } -xercesc::DOMDocument* constructDocument( +} + +namespace InputXSLT { + +xercesc::DOMDocument* FunctionReadFile::constructDocument( + const FilesystemContext&, const boost::filesystem::path& filePath ) { xercesc::DOMDocument* const domDocument( @@ -68,58 +70,3 @@ xercesc::DOMDocument* constructDocument( } } - -namespace InputXSLT { - -FunctionReadFile::FunctionReadFile(): - document_cache_(std::make_shared<DomDocumentCache>()) { } - -xalan::XObjectPtr FunctionReadFile::execute( - xalan::XPathExecutionContext& executionContext, - xalan::XalanNode*, - const xalan::XObjectPtr argument, - const xalan::Locator* locator -) const { - const FilesystemContext fsContext(locator); - - const boost::filesystem::path filePath( - fsContext.resolve(argument->str()) - ); - - DomDocumentCache::optional_item optionalCachedDocument( - this->document_cache_->get(filePath.string()) - ); - - if ( !optionalCachedDocument.first ) { - optionalCachedDocument = this->document_cache_->create( - filePath.string(), - constructDocument(filePath) - ); - } - - xalan::XPathExecutionContext::BorrowReturnMutableNodeRefList nodeList( - executionContext - ); - - nodeList->addNodes( - *optionalCachedDocument.second->getXalanDocument() - ->getDocumentElement() - ->getChildNodes() - ); - - return executionContext.getXObjectFactory().createNodeSet(nodeList); -} - -FunctionReadFile* FunctionReadFile::clone( - xalan::MemoryManager& manager) const { - return xalan::XalanCopyConstruct(manager, *this); -} - -const xalan::XalanDOMString& FunctionReadFile::getError( - xalan::XalanDOMString& result) const { - result.assign("The read-file() function expects one argument of type string."); - - return result; -} - -} |