diff options
Diffstat (limited to 'src/support')
-rw-r--r-- | src/support/filesystem_context.cc | 6 | ||||
-rw-r--r-- | src/support/filesystem_context.h | 2 | ||||
-rw-r--r-- | src/support/include_entity_resolver.cc | 34 | ||||
-rw-r--r-- | src/support/include_entity_resolver.h | 2 |
4 files changed, 27 insertions, 17 deletions
diff --git a/src/support/filesystem_context.cc b/src/support/filesystem_context.cc index eba7e45..a18ec43 100644 --- a/src/support/filesystem_context.cc +++ b/src/support/filesystem_context.cc @@ -8,11 +8,9 @@ namespace InputXSLT { -FilesystemContext::FilesystemContext(const xalan::Locator* locator): +FilesystemContext::FilesystemContext(const boost::filesystem::path& path): path_(boost::filesystem::canonical( - boost::filesystem::path( - *XercesStringGuard<char>(locator->getSystemId()) + 7 - ).parent_path().string() + path.parent_path() )) { } FilesystemContext::FilesystemContext(const std::string& path): diff --git a/src/support/filesystem_context.h b/src/support/filesystem_context.h index 1f574de..9741039 100644 --- a/src/support/filesystem_context.h +++ b/src/support/filesystem_context.h @@ -15,7 +15,7 @@ namespace InputXSLT { class FilesystemContext { public: - explicit FilesystemContext(const xalan::Locator*); + explicit FilesystemContext(const boost::filesystem::path&); explicit FilesystemContext(const std::string&); boost::filesystem::path resolve(const std::string&) const; diff --git a/src/support/include_entity_resolver.cc b/src/support/include_entity_resolver.cc index e63a3c4..5e106f2 100644 --- a/src/support/include_entity_resolver.cc +++ b/src/support/include_entity_resolver.cc @@ -10,6 +10,13 @@ namespace { using InputXSLT::XercesStringGuard; +inline boost::filesystem::path getPathFromSystemId( + const XMLCh* const systemId) { + return boost::filesystem::path( + *XercesStringGuard<char>(systemId) + 7 + ); +} + boost::optional<std::string> extractFilePath(const XMLCh* const rawPath) { const std::string filePath = *XercesStringGuard<char>(rawPath); const std::size_t leadingDelimiter = filePath.find_first_of('['); @@ -42,21 +49,24 @@ xercesc::InputSource* IncludeEntityResolver::resolveEntity( const XMLCh* const systemId ) { if ( systemId != nullptr ) { - if ( auto filePath = extractFilePath(systemId) ) { - if ( auto resolvedPath = this->resolve(*filePath) ) { - return new xercesc::LocalFileInputSource( - *XercesStringGuard<XMLCh>((*resolvedPath).string()) - ); - } else { - return new xercesc::LocalFileInputSource( - *XercesStringGuard<XMLCh>(*filePath) - ); - } + return new xercesc::LocalFileInputSource( + *XercesStringGuard<XMLCh>(this->resolve(systemId).string()) + ); + } else { + return nullptr; + } +} + +boost::filesystem::path IncludeEntityResolver::resolve( + const XMLCh* const rawPath) const { + if ( auto filePath = extractFilePath(rawPath) ) { + if ( auto resolvedPath = this->resolve(*filePath) ) { + return *resolvedPath; } else { - return nullptr; + return getPathFromSystemId(rawPath); } } else { - return nullptr; + return getPathFromSystemId(rawPath); } } diff --git a/src/support/include_entity_resolver.h b/src/support/include_entity_resolver.h index 28992d6..c8f2867 100644 --- a/src/support/include_entity_resolver.h +++ b/src/support/include_entity_resolver.h @@ -22,6 +22,8 @@ class IncludeEntityResolver : public xercesc::EntityResolver { const XMLCh* const ); + boost::filesystem::path resolve( + const XMLCh* const) const; boost::optional<boost::filesystem::path> resolve( const std::string&) const; |