#ifndef ARABICA_XSLT_VALUE_OF_HANDLER_HPP #define ARABICA_XSLT_VALUE_OF_HANDLER_HPP #include #include "../xslt_value_of.hpp" namespace Arabica { namespace XSLT { template class ValueOfHandler : public SAX::DefaultHandler { typedef StylesheetConstant SC; public: ValueOfHandler(CompilationContext& context) : context_(context), valueOf_(0) { } // ValueOfHandler virtual void startElement(const string_type& /* namespaceURI */, const string_type& /* localName */, const string_type& qName, const SAX::Attributes& atts) { if(valueOf_ == 0) { static const ValueRule rules[] = { { SC::select, true, 0, 0 }, { SC::disable_output_escaping, false, SC::no, SC::AllowedYesNo }, { 0, false, 0, 0 } }; std::map attrs = gatherAttributes(qName, atts, rules); valueOf_ = new ValueOf(context_.xpath_expression(attrs[SC::select]), attrs[SC::disable_output_escaping] == SC::yes); return; } // if(valueOf_ == 0) throw SAX::SAXException(string_adaptor::asStdString(qName) + " can not contain elements"); } // startElement virtual void endElement(const string_type& /* namespaceURI */, const string_type& /* localName */, const string_type& /* qName */) { context_.parentContainer().add_item(valueOf_); context_.pop(); } // endElement virtual void characters(const string_type& ch) { verifyNoCharacterData(ch, SC::value_of); } // characters private: CompilationContext& context_; ValueOf* valueOf_; }; // class ValueOfHandler } //namespace XSLT } //namespace Arabica #endif