aboutsummaryrefslogtreecommitdiff
path: root/src/function/read_file.cc
diff options
context:
space:
mode:
authorAdrian Kummerländer2014-05-22 19:58:15 +0200
committerAdrian Kummerländer2014-05-22 19:58:15 +0200
commit4d0569669e01434b3bb9f689cd176f590344bea8 (patch)
tree131ea5f48f34bafd01ffa133971739f68e551556 /src/function/read_file.cc
parentbbe16940e7a6f97128e99ad7642b964e48ecde2e (diff)
downloadInputXSLT-4d0569669e01434b3bb9f689cd176f590344bea8.tar
InputXSLT-4d0569669e01434b3bb9f689cd176f590344bea8.tar.gz
InputXSLT-4d0569669e01434b3bb9f689cd176f590344bea8.tar.bz2
InputXSLT-4d0569669e01434b3bb9f689cd176f590344bea8.tar.lz
InputXSLT-4d0569669e01434b3bb9f689cd176f590344bea8.tar.xz
InputXSLT-4d0569669e01434b3bb9f689cd176f590344bea8.tar.zst
InputXSLT-4d0569669e01434b3bb9f689cd176f590344bea8.zip
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
Diffstat (limited to 'src/function/read_file.cc')
-rw-r--r--src/function/read_file.cc13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/function/read_file.cc b/src/function/read_file.cc
index 5ded1ac..85f834d 100644
--- a/src/function/read_file.cc
+++ b/src/function/read_file.cc
@@ -28,10 +28,21 @@ xercesc::DOMDocument* FunctionReadFile::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,