From 4d0569669e01434b3bb9f689cd176f590344bea8 Mon Sep 17 00:00:00 2001 From: Adrian Kummerländer Date: Thu, 22 May 2014 19:58:15 +0200 Subject: Added include path resolution to external file access functions * if a given file can not be located relative to the transformation's location both "read-file" and "read-xml-file" will now try to resolve the path using the IncludeEntityResolver * all external functions based on the FunctionBase template are now provided with a pointer to a IncludeEntityResolver instance * it is determined by the external function implementation whether include path resolution will be used --- src/function/read_xml_file.cc | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/function/read_xml_file.cc') diff --git a/src/function/read_xml_file.cc b/src/function/read_xml_file.cc index 5f1d47d..b9246e6 100644 --- a/src/function/read_xml_file.cc +++ b/src/function/read_xml_file.cc @@ -38,10 +38,21 @@ xercesc::DOMDocument* FunctionReadXmlFile::constructDocument( const FilesystemContext& fsContext, const FunctionBase::parameter_tuple& parameters ) { - const boost::filesystem::path filePath( + boost::filesystem::path filePath( fsContext.resolve(std::get<0>(parameters)) ); + if ( !(boost::filesystem::exists(filePath) && + boost::filesystem::is_regular_file(filePath)) ) { + auto resolvedPath = this->include_resolver_->resolve( + std::get<0>(parameters) + ); + + if ( resolvedPath.first ) { + filePath = resolvedPath.second; + } + } + xercesc::DOMDocument* const domDocument( xercesc::DOMImplementation::getImplementation()->createDocument( nullptr, -- cgit v1.2.3