arabica/include/XSLT/impl/handler/xslt_value_of_handler.hpp

66 lines
2.2 KiB
C++
Raw Normal View History

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