diff options
author | Adrian Kummerlaender | 2014-09-06 14:23:17 +0200 |
---|---|---|
committer | Adrian Kummerlaender | 2014-09-06 14:23:17 +0200 |
commit | 5e7b8b9558fec9d58716c46666d62a055a39f0be (patch) | |
tree | 7a9623af56595d246af4fb1619533c0018f44d6d | |
parent | 216fcea2c8b52a5657d879628a27a76cb1fef2e3 (diff) | |
download | InputXSLT-5e7b8b9558fec9d58716c46666d62a055a39f0be.tar InputXSLT-5e7b8b9558fec9d58716c46666d62a055a39f0be.tar.gz InputXSLT-5e7b8b9558fec9d58716c46666d62a055a39f0be.tar.bz2 InputXSLT-5e7b8b9558fec9d58716c46666d62a055a39f0be.tar.lz InputXSLT-5e7b8b9558fec9d58716c46666d62a055a39f0be.tar.xz InputXSLT-5e7b8b9558fec9d58716c46666d62a055a39f0be.tar.zst InputXSLT-5e7b8b9558fec9d58716c46666d62a055a39f0be.zip |
Changed system-ID of primary transformation to working directory
* this change was needed so that one is able to apply transformations located in e.g. a central directory as if they where located in the working directory
** otherwise e.g. the BuildXSLT transformation would have to be copied into every project that requires it
* implemented StreamInputSource wrapper for boost::filesystem::ifstream and xalan::XSLTInputSource
** this is needed because the boost::filesystem::ifstream instance has to exist as long as the xalan::XSLTInputSource it is bound to
** i.e. a simple helper function to instantiate the source and set the working directory would have not been sufficient
-rw-r--r-- | ixslt.cc | 39 |
1 files changed, 35 insertions, 4 deletions
@@ -12,6 +12,7 @@ #include "platform_guard.h" #include "transformer_facade.h" +#include "support/xerces_string_guard.h" namespace { @@ -35,6 +36,31 @@ class WarningGuard { }; +class StreamInputSource { + public: + StreamInputSource( + const boost::filesystem::path& actualPath, + const boost::filesystem::path& contextPath + ): + file_(actualPath), + source_(file_) { + this->source_.setSystemId( + *InputXSLT::XercesStringGuard<XMLCh>( + "file://" + contextPath.string() + ) + ); + } + + xalan::XSLTInputSource& operator*() { + return this->source_; + } + + private: + boost::filesystem::ifstream file_; + xalan::XSLTInputSource source_; + +}; + boost::optional<boost::program_options::variables_map> input( int argc, char** argv @@ -133,6 +159,11 @@ bool process(const boost::program_options::variables_map& variables) { InputXSLT::PlatformGuard platform(includePath); + StreamInputSource transformationSource( + variables["transformation"].as<std::string>(), + boost::filesystem::current_path() + ); + if ( variables.count("target") ) { boost::filesystem::ofstream file( variables["target"].as<std::string>() @@ -144,13 +175,13 @@ bool process(const boost::program_options::variables_map& variables) { platform.getEntityResolver(), file, variables["input"].as<std::string>().data(), - variables["transformation"].as<std::string>().data() + *transformationSource ); } else { return generate( platform.getEntityResolver(), file, - variables["transformation"].as<std::string>().data() + *transformationSource ); } } else { @@ -162,13 +193,13 @@ bool process(const boost::program_options::variables_map& variables) { platform.getEntityResolver(), std::cout, variables["input"].as<std::string>().data(), - variables["transformation"].as<std::string>().data() + *transformationSource ); } else { return generate( platform.getEntityResolver(), std::cout, - variables["transformation"].as<std::string>().data() + *transformationSource ); } } |