diff --git a/include/XSLT/impl/xslt_execution_context.hpp b/include/XSLT/impl/xslt_execution_context.hpp index d80e744d..96b48a66 100644 --- a/include/XSLT/impl/xslt_execution_context.hpp +++ b/include/XSLT/impl/xslt_execution_context.hpp @@ -72,7 +72,11 @@ public: return !to_msg_ ? sink_ : message_sink_.asOutput(); } // sink void redirectToMessageSink() { ++to_msg_; } - void revertFromMessageSink() { --to_msg_; } + void revertFromMessageSink() { + --to_msg_; + if (to_msg_ == 0) + message_sink_.flush(); + } const Arabica::XPath::ExecutionContext& xpathContext() const { return xpathContext_; } diff --git a/include/XSLT/impl/xslt_sink.hpp b/include/XSLT/impl/xslt_sink.hpp index 6fa49732..b90c0f9d 100644 --- a/include/XSLT/impl/xslt_sink.hpp +++ b/include/XSLT/impl/xslt_sink.hpp @@ -110,11 +110,13 @@ public: ~StreamSink() { - stream_.flush(); + flush(); } // ~StreamSink virtual Output& asOutput() { return *this; } + void flush() { stream_ << std::endl; } + protected: typedef typename Output::Settings Settings;