diff --git a/include/XSLT/impl/handler/xslt_item_container_handler.hpp b/include/XSLT/impl/handler/xslt_item_container_handler.hpp index 39ceaa6f..fda27ad5 100644 --- a/include/XSLT/impl/handler/xslt_item_container_handler.hpp +++ b/include/XSLT/impl/handler/xslt_item_container_handler.hpp @@ -67,7 +67,7 @@ public: for(std::string::const_iterator i = ch.begin(), e = ch.end(); i != e; ++i) if(!Arabica::XML::is_space(*i)) { - container_->add_item(new Text(ch)); + container_->add_item(new Text >(ch)); return; } // if ... } // characters @@ -153,7 +153,7 @@ const ChildElement* AllowedChildren() { "message", CreateHandler}, { "number", CreateHandler}, { "processing-instruction", CreateHandler }, - { "text", CreateHandler }, + { "text", CreateHandler > > }, { "value-of", CreateHandler }, { "variable", CreateHandler > }, { 0, 0 } diff --git a/include/XSLT/impl/handler/xslt_text_handler.hpp b/include/XSLT/impl/handler/xslt_text_handler.hpp index b7fa99cf..9f246611 100644 --- a/include/XSLT/impl/handler/xslt_text_handler.hpp +++ b/include/XSLT/impl/handler/xslt_text_handler.hpp @@ -8,49 +8,50 @@ namespace Arabica namespace XSLT { -class TextHandler : public SAX::DefaultHandler +template +class TextHandler : public SAX::DefaultHandler { public: - TextHandler(CompilationContext& context) : + TextHandler(CompilationContext& context) : context_(context), text_(0) { } // TextHandler - virtual void startElement(const std::string& /* namespaceURI */, - const std::string& /* localName */, - const std::string& qName, - const SAX::Attributes& atts) + virtual void startElement(const string_type& /* namespaceURI */, + const string_type& /* localName */, + const string_type& qName, + const SAX::Attributes& atts) { if(text_ == 0) { static const ValueRule rules[] = { { "disable-output-escaping", false, No, AllowedYesNo }, { 0, false, 0, 0 } }; - text_ = new Text(gatherAttributes(qName, atts, rules)["disable-output-escaping"] == Yes); + text_ = new Text(gatherAttributes(qName, atts, rules)["disable-output-escaping"] == Yes); return; } // if(text_ == 0) throw SAX::SAXException(qName + " can not contain elements"); } // startElement - virtual void endElement(const std::string& /* namespaceURI */, - const std::string& /* localName */, - const std::string& /* qName */) + virtual void endElement(const string_type& /* namespaceURI */, + const string_type& /* localName */, + const string_type& /* qName */) { text_->set(buffer_); context_.parentContainer().add_item(text_); context_.pop(); } // endElement - virtual void characters(const std::string& ch) + virtual void characters(const string_type& ch) { buffer_ += ch; } // characters private: - CompilationContext& context_; - Text* text_; - std::string buffer_; + CompilationContext& context_; + Text* text_; + string_type buffer_; }; // class TextHandler } // namespace XSLT diff --git a/include/XSLT/impl/xslt_text.hpp b/include/XSLT/impl/xslt_text.hpp index 188a3c87..8e8f42c1 100644 --- a/include/XSLT/impl/xslt_text.hpp +++ b/include/XSLT/impl/xslt_text.hpp @@ -8,6 +8,7 @@ namespace Arabica namespace XSLT { +template class Text : public Item { public: @@ -16,16 +17,16 @@ public: { } // Text - Text(const std::string& text) : + Text(const string_type& text) : text_(text), disable_(false) { } // Text - void set(const std::string& text) { text_ = text; } + void set(const string_type& text) { text_ = text; } - virtual void execute(const DOM::Node& /* node */, - ExecutionContext& context) const + virtual void execute(const DOM::Node& /* node */, + ExecutionContext& context) const { if(disable_) context.sink().disableOutputEscaping(true); @@ -37,8 +38,8 @@ public: } // execute private: - std::string text_; - bool disable_; + string_type text_; + const bool disable_; }; // class Text } // namespace XSLT