arabica/include/XSLT/impl/xslt_message.hpp

57 lines
1.3 KiB
C++
Raw Normal View History

2007-07-19 17:01:42 +00:00
#ifndef ARABICA_XSLT_MESSAGE_HPP
#define ARABICA_XSLT_MESSAGE_HPP
#include "xslt_item.hpp"
namespace Arabica
{
namespace XSLT
{
2012-11-04 22:34:40 +00:00
template<class stringT, class adaptorT>
2012-11-08 16:18:49 +00:00
class Message : public ItemContainer<stringT, adaptorT>
2007-07-19 17:01:42 +00:00
{
public:
2012-11-04 22:34:40 +00:00
typedef stringT string_type;
typedef adaptorT string_adaptor;
2007-07-19 17:01:42 +00:00
Message(bool terminate) :
terminate_(terminate)
{
} // Message
virtual ~Message() { }
2012-11-08 17:13:33 +00:00
virtual void execute(const DOM::Node<string_type, string_adaptor>& node, ExecutionContext<string_type, string_adaptor>& context) const
2007-07-19 17:01:42 +00:00
{
RedirectionFrame toMessageSink(context);
2013-01-05 21:26:35 +00:00
this->execute_children(node, context);
2007-07-19 17:01:42 +00:00
if(terminate_)
throw SAX::SAXException("Stylesheet terminated by xsl:message");
} // execute
private:
2012-11-04 17:07:41 +00:00
const bool terminate_;
class RedirectionFrame
{
public:
2012-11-08 17:13:33 +00:00
RedirectionFrame(ExecutionContext<string_type, string_adaptor>& context) : context_(context) { context_.redirectToMessageSink(); }
~RedirectionFrame() { context_.revertFromMessageSink(); }
private:
2012-11-08 17:13:33 +00:00
ExecutionContext<string_type, string_adaptor>& context_;
RedirectionFrame();
RedirectionFrame(const RedirectionFrame&);
bool operator=(const RedirectionFrame&);
}; // class RedirectionFrame
2007-07-19 17:01:42 +00:00
}; // class Message
} // namespace XSLT
} // namespace Arabica
#endif